﻿/// <reference path="vswd-ext_2.2.js" />

Ext.namespace('Ext.ms02data');

Ext.ms02data.commandmodels = [
    ['0', _TrackerMain_GTVTSeries],
    ['1', _TrackerMain_MTMVTSeries]
];

if (showGBCommand)
    Ext.ms02data.commandmodels.push(['2', _TrackerMain_GB]);

if (typeof (Tzonecommand) != 'undefined') {
    if(Tzonecommand)
        Ext.ms02data.commandmodels.push(['3', 'AVL02']);
}

Ext.ms02data.gprscommands = [
    ['0', _CommandExpression_TrackOnDemand],
    ['1', _CommandExpression_SetGPRSInterval],
    ['2', _CommandExpression_SetDistanceInverval],
    ['3', _CommandExpression_Authorization],
    ['4', _CommandExpression_SetOverSpeed],
    ['5', _CommandExpression_SetMovementAlarm],
    ['6', _CommandExpression_SetGeoFence],
    ['7', _CommandExpression_SetGeoFenceCircle],
    ['8', _CommandExpression_SetExtendedFunctions],
    ['9', _CommandExpression_Enginelimited],
    ['10', _CommandExpression_EngineUnlimited],
    ['11', _CommandExpression_TriggeredAlarms],
    ['12', _CommandExpression_SetSleepMode],
    ['13',_CommandExpression_SetPowerDown],
    ['14', _CommandExpression_SetWiretapping],
    ['15', _CommandExpression_SetTimeZone],
    ['16', _CommandExpression_GPRS_SetVeerReport],
    ['17', _CommandExpression_GPRS_SetHeartBeat],
    ['18', _CommandExpression_RebootGPS],
    ['19', _CommandExpression_SetGPSAntennaAlarm],
    ['20', _CommandExpression_GPRS_SetLogInterval],
    ['21', _CommandExpression_GPRS_FormatLoggedData],
//['19',_CommandExpression_GPRS_ReadLoggedData],
    ['22', _CommandExpression_GPRS_ReadInterval],
    ['23', _CommandExpression_ReadAuthorization],
    ['24', _CommandExpression_ReasSNIMEIFirmware],
    ['25', _CommandExpression_ClearKilometers],
    ['26', _CommandExpression_SetGPRS],
    ['27',_CommandExpression_EngineCheck]
//['21',_CommandExpression_SetSMSCommnadHeader]
//,['21',_CommandExpression_Initialization]
];

Ext.ms02data.mt88commands = [
    ['0', _CommandExpression_TrackOnDemand],
    ['1', _CommandExpression_GPRS_SetHeartBeat],
    ['2', _CommandExpression_SetIntervalCounter],
    ['3', _CommandExpression_GPRS_SetVeerReport],
    ['4', _CommandExpression_SetDistanceInverval],
    ['5', _CommandExpression_SetGPRS],
    ['6', _CommandExpression_SetSecondGPRS],
    ['7', _CommandExpression_SetAuthorizePhoneAndFlag],
    ['8', _CommandExpression_GetAuthorizePhoneAndFlag],
    ['9', _CommandExpression_SetSMSEventFlag],
    ['10', _CommandExpression_DeleteSMSEventFlag],
    ['11', _CommandExpression_SetGeoFence],
    ['12', _CommandExpression_ReadGeoFence],
    ['13', _CommandExpression_DeleteGeoFence],
    ['14', _CommandExpression_SetOverSpeed],
    ['15', _CommandExpression_SetTowAlert],
    ['16', _CommandExpression_SetExtendedFunctions],
    //['17', _CommandExpression_SetGPSSleepMode],
    //['18', _CommandExpression_SetSleepTime],
    ['19', _CommandExpression_GPRS_SetLogInterval],
    ['20', _CommandExpression_SetSMSTimeZone],
    ['21', _CommandExpression_SetGPRSTimeZone],
    ['22', _CommandExpression_SetSMSCommnadHeader],
    ['23', _CommandExpression_SetEventFlagforGPRS],
    ['24', _CommandExpression_GetEventFlagforGPRS],
    ['25', _CommandExpression_Outputcontrol],
    ['26', _CommandExpression_ReadFirmwareandSN],
//['0',_CommandExpression_GPRS_ReadLoggedData],
    ['27', _CommandExpression_RebootGSM],
    ['28', _CommandExpression_RebootGPS],
//['28',_CommandExpression_Initialization]
    ['29', _CommandExpression_SendSMSFromGPRS]
//,['29', _CommandExpression_ReadEEPData]
//,['33', _CommandExpression_DeleteGPRSEvent]
//,['32', _CommandExpression_SetDNSServerIP]
    , ['30', _CommandExpression_ProtocolControl]
    , ['31', _CommandExpression_GetAllPictureName]
    , ['32', _CommandExpression_DelAllPicture]
    , ['33', _CommandExpression_GetPhotoEventFlag]
    , ['34', _CommandExpression_SetPhotoEventFlag]
    , ['35', _CommandExpression_TakePhoto]
    , ['36', _CommandExpression_RemoveBuffer]
    , ['37', _CommandExpression_GPRS_Message]
    //, ['38', _CommandExpression_GPRS_Control_Message]
    //, ['39', _CommandExpression_GPRS_Message]
    , ['40', _CommandExpression_ReadAuthNO]
    , ['41', _CommandExpression_SetGroupFunctionNO]
    , ['42', _CommandExpression_SetWiretapping]
    , ['43', _CommandExpression_SetSmartSleepMode]
    , ['44', _CommandExpression_ClearKilometersRuntime]
    , ['45', _CommandExpression_SetKilometersRuntime]
    , ['46', _CommandExpression_ReadIPPort]
    , ['47', _CommandExpression_ReadAPN]
    , ['48', _SettingTool_ReadAllParams]
    //,['9999','Test']
//   , ['44', _CommandExpression_FuelAlarmSettings]
////RFID
//     , ['45', _CommandExpression_AuthRFID]
//    , ['46', _CommandExpression_BatchAuthRFID]
//     , ['47', _CommandExpression_BatchDelRFID]
//    , ['48', _CommandExpression_CheckRFIDAuth]
//    , ['49', _CommandExpression_CheckRFIDDBSync]
//     , ['50', _CommandExpression_DelAuthedRFID]
//    , ['51', _CommandExpression_ReadAuthedRFID]
//     , ['52', _CommandExpression_Set_BaseMileage]
//     , ['53', _CommandExpression_UserDefinedCommand]
//    , ['54', _CommandExpression_OTAUpgrade]
//    , ['55', _CommandExpression_CancelOTA]
];

//Ext.ms02data.tzonecommands = [
//    ['0', _CommandExpression_TrackOnDemand],
//    ['1', _NewForText_ChangePassword],
//    ['2', _CommandExpression_TrackBySMS],
//    ['3', _CommandExpression_SetSMSCallSMSTo],
//    ['4', _CommandExpression_LowPowerAlarm],
//    ['5', _CommandExpression_SetOverSpeed],
//    ['6', _CommandExpression_SetGeoFence],
//    ['7', _CommandExpression_SetExtendedFunctions],
//    ['8', _CommandExpression_GSMBand],
//    ["11", _CommandExpression_SetIPPort],
//    ["12", _CommandExpression_SetAPN],
//    ["13", _CommandExpression_SetGPRSInterval],
//    ["14", _CommandExpression_EnableGPRSTracking],
//    ['15', _CommandExpression_TrembleSensorSwitch],
//    ['16', _CommandExpression_SetTheModule],
//    ['17', _CommandExpression_ControlIOPort],
//    ['18', _CommandExpression_HeartBeatSwitch],
//    ['19', _CommandExpression_GPRS_SetHeartBeat],
//    ['20', _CommandExpression_HeartBeatInit],
//    ['21', _CommandExpression_IntoSleepWithOutTremble],
//    ['22', _CommandExpression_WakeupfromTremble],
//    ['23', _CommandExpression_Parkingalarm],
//    ['24', _CommandExpression_GetIMEI],
//    ['33',_CommandExpression_Acceleration]
//];

Ext.ms02data.smsgtdata = [
           ["0", _CommandExpression_TrackBySMS],
           ["1", _CommandExpression_TrackByPresetInterval],
           ["2", _CommandExpression_SetGPRSInterval],
           ["3", _CommandExpression_SetIPPort],
           ["4", _CommandExpression_SetAPN],
//["5", _CommandExpression_SetDNSServerIP],
//["5", _CommandExpression_SetLowPower],
           ["5", _CommandExpression_SetOverSpeed],
           ["6", _CommandExpression_SetMovementAlarm],
           ["7", _CommandExpression_SetGeoFence],
           ["8", _CommandExpression_SetGeoFenceCircle],
           ["9", _CommandExpression_SetExtendedFunctions],
           ["10", _CommandExpression_Enginelimited],
           ["11", _CommandExpression_EngineUnlimited],
           ["12", _CommandExpression_SetSleepMode],
           ["13", _CommandExpression_SetWiretapping],
           ["14", _CommandExpression_SetTimeZone],
           ["15", _CommandExpression_Authorization],
           ["16", _CommandExpression_EnableGPRSTracking],
           ["17", _CommandExpression_RebootGPS],
           ["18", _CommandExpression_RebootGSM],
//["19", _CommandExpression_GetVersionNoAndSerialNO],
           ["19", _CommandExpression_GetIMEI],
           ["20", _CommandExpression_ChangePassword],
//["22", _CommandExpression_PasswordInitialization],
           ["21", _CommandExpression_SetSMSInitials],
           ["22", _CommandExpression_GPRS_SetLogInterval],
           ["23", _CommandExpression_Initialization]
];

Ext.ms02data.smsmt88data = [
           ["0", _CommandExpression_TrackBySMS],
           ["1", _CommandExpression_TrackOnDemand],
           ["2", _CommandExpression_SetSMSIntervalCounter],
           ['3', _CommandExpression_SetIntervalCounter],
           ["4", _CommandExpression_SetDistanceInverval],
           ["5", _CommandExpression_SetGPRS],
           ["6", _CommandExpression_SetDNSServerIP],
           ["7", _CommandExpression_SetSecondGPRS],
           ["8", _CommandExpression_GetAuthorizePhoneAndFlag],
           ["9", _CommandExpression_SetAuthorizePhoneAndFlag],
           ["10", _CommandExpression_SetOverSpeed],
           ["11", _CommandExpression_SetGeoFence],
           ["12", _CommandExpression_SetTowAlert],
           ["13", _CommandExpression_DeleteGeoFence],
           ["14", _CommandExpression_SetSMSEventFlag],
           ["15", _CommandExpression_DeleteSMSEventFlag],
           ["16", _CommandExpression_SetExtendedFunctions],
           //["17", _CommandExpression_SetGPSSleepMode],
           //["18", _CommandExpression_SetSleepTime],
           ["19", _CommandExpression_SetSMSTimeZone],
           ["20", _CommandExpression_SetSMSCommnadHeader],
           ["21", _CommandExpression_Outputcontrol],
           ["22", _CommandExpression_ReadFirmwareandSN],
           ["23", _CommandExpression_RebootGSM],
           ["24", _CommandExpression_RebootGPS],
           ["25", _CommandExpression_Initialization],
           ["26", _CommandExpression_PasswordInitialization],
           ["27", _CommandExpression_ChangePassword]
];

Ext.ms02data.ledcommands = [
   //["0", _CommandExpression_LED_AddAdvertisement],
   //["1", _CommandExpression_LED_DelAdvertisement],
   ["2", _CommandExpression_LED_DelAllAdvertisement],
   ["3", _CommandExpression_LED_GetAdvertisementCount],
   ["4", _CommandExpression_LED_GetAdvertisement],
   ["5",_CommandExpression_LED_SendMessage],
   ["6", _CommandExpression_LED_BreakMessage],
   ["7", _CommandExpression_LED_SetAlarm],
   ["8",_CommandExpression_LED_ShowAlarm],
   ["9", _CommandExpression_LED_HideAlarm],
   ["10", _CommandExpression_LED_SetDefaultMessage],
   ["11",_CommandExpression_LED_SetTime],
   ["12", _CommandExpression_LED_GetTime],
   ["13", _CommandExpression_LED_SetBrightness],
   ["14",_CommandExpression_LED_GetBrightness],
   ["15", _CommandExpression_LED_SetPowerOnWaitingTime],
   //["16", _CommandExpression_LED_SearchWorkingStatus],
   ["17",_CommandExpression_LED_TimerSwitch],
   ["18", _CommandExpression_LED_LEDSwitch]
   //["19", _CommandExpression_LED_LightTest],
   //["20",_CommandExpression_LED_UpgradeCNLib],
   //["21", _CommandExpression_LED_UpgradeENLib],
  // ["22", _CommandExpression_LED_SetBaudrate]

];

if (typeof(rfidDefined) !='undefined') {
    if(rfidDefined){
        Ext.ms02data.mt88commands.push(['200', _CommandExpression_AuthRFID]);
        Ext.ms02data.mt88commands.push(['201', _CommandExpression_BatchAuthRFID]);
        Ext.ms02data.mt88commands.push(['202', _CommandExpression_BatchDelRFID]);
        Ext.ms02data.mt88commands.push(['203', _CommandExpression_CheckRFIDAuth]);
        Ext.ms02data.mt88commands.push(['204', _CommandExpression_CheckRFIDDBSync]);
        Ext.ms02data.mt88commands.push(['205', _CommandExpression_ReadAuthedRFID]);
        Ext.ms02data.mt88commands.push(['206', _CommandExpression_Set_BaseMileage]);
    }
}

if (typeof(vjpDefined)!='undefined') {
    if(vjpDefined){
        Ext.ms02data.mt88commands.push(['100', _CommandExpression_PulseCalibration]);
        Ext.ms02data.mt88commands.push(['101', _CommandExpression_InformationCharacter]);
        Ext.ms02data.mt88commands.push(['102', _CommandExpression_SetPrintPeriod]);
    }
}

if (typeof(vjpDefined2)!='undefined') {
    if(vjpDefined2){
        Ext.ms02data.mt88commands.push(['103', _CommandExpression_CheckIgnition]);
        Ext.ms02data.mt88commands.push(['104', _CommandExpression_GPRSIntervalWhenIgnitionOff]);
    }

}

if(typeof(trackerExtendSensorDefined)!='undefined'){
    if(trackerExtendSensorDefined){
        Ext.ms02data.mt88commands.push(['105', _CommandExpression_AsyncExtendSensor]);
    }
}

//if(typeof(ledDefined) != 'undefined'){
//    if(ledDefined){
//        Ext.ms02data.mt88commands.push(['107', _CommandExpression_LED]);
//    }
//}

if(typeof(gpscloseDefined) != 'undefined'){
    if(gpscloseDefined){
        Ext.ms02data.mt88commands.push(['108', _CommandExpression_GPSOpenClose]);
    }
}

if(typeof(staticsensor)!='undefined'){
    if(staticsensor){
        Ext.ms02data.mt88commands.push(['109', _CommandExpression_SetFuelAlarm]);
    }
}

if (typeof (showRFIDcontrolout1) != 'undefined') {
    if (showRFIDcontrolout1) {
        Ext.ms02data.mt88commands.push(['110', _CommandExpression_RFIDOut1]);
    }
}

if(typeof (show3DWakeUpCommand) != 'undefined'){
    if(show3DWakeUpCommand){
        Ext.ms02data.mt88commands.push(['111',_CommandExpression_3DWakeUpSet]);
    }
}

if(typeof(showEngineCheckCommand) != 'undefined'){
    if(showEngineCheckCommand){
        Ext.ms02data.mt88commands.push(['112', _CommandExpression_EngineCheck]);
    }
}
if (typeof (showFuelDown) != 'undefined') {
    if (showFuelDown) {
        Ext.ms02data.mt88commands.push(['113', _CommandExpression_SetFuelDown]);
    }
}

Ext.ms02data.gbcommands = [
    ["0", _CommandExpression_GBSetParams],
    ["1", _CommandExpression_GBCheckParams],
    ["2", _CommandExpression_GBControlTracker],
    ["3", _CommandExpression_GBCheckLocation],
    ["4", _CommandExpression_GBTempLocationTrack],
    ["5", _CommandExpression_GBSendText],
    ["6", _CommandExpression_GBSetEvent],
    ["7", _CommandExpression_GBQuestion],
    ["8", _CommandExpression_GBSetMenu],
    ["9", _CommandExpression_GBInfoService],
    ["10", _CommandExpression_GBPhoneTo],
    ["11", _CommandExpression_GBSetPhoneBook],
    ["12", _CommandExpression_GBControlVehicle],
    ["13", _CommandExpression_GBSetGeoFence],
    ["21", _CommandExpression_GBSetLog],
    ["22", _CommandExpression_GBLogParamSet],
    ["23", _CommandExpression_GBTakePhoto],
    ["24", _CommandExpression_GBMultimediaSearch],
    ["25", _CommandExpression_GBMultimediaUpload],
    ["26", _CommandExpression_GBBeginRecordVoice],
    ["27", _CommandExpression_GBTransData],
    ["28", _CommandExpression_GBManulaParams]
];

Ext.ms02data.eventcodenames = [
          ['1', _AlarmResource_SOSButton_Pressed_Input1_Active],
          ['2', _AlarmResource_ButtonB_Pressed_Input2_Active],
          ['3', _AlarmResource_ButtonC_Pressed_Input3_Active],
          ['4', _AlarmResource_Input4_Active],
          ['5', _AlarmResource_Input5_Active],
          ['9', _AlarmResource_SOSButton_Released_Input1_InActive],
          ['10', _AlarmResource_ButtonB_Released_Input2_InActive],
          ['11', _AlarmResource_ButtonC_Released_Input3_InActive],
          ['12', _AlarmResource_Input4_InActive],
          ['13', _AlarmResource_Input5_InActive],
          ['17', _AlarmResource_LowBattery],
          ['18', _AlarmResource_LowExternalPower],
          ['19', _AlarmResource_OverSpeed],
          ['20', _AlarmResource_EnterGeofence],
          ['21', _AlarmResource_ExitGeofence],
          ['22', _AlarmResource_ExternalPowerOn],
          ['23', _AlarmResource_ExternalPowerOff],
          ['24', _AlarmResource_EnterGPSBlindAlarm],
          ['25', _AlarmResource_ExitGPSBlindAlarm],
          ['26', _AlarmResource_EnterSleep],
          ['27', _AlarmResource_ExitSleep],
          ['28', _AlarmResource_GPSAntennaCut],
          ['29', _AlarmResource_TurnOnAlarm],
          ['30', _AlarmResource_Impact],
          ['31', _AlarmResource_HeartbeatReport],
          ['32', _AlarmResource_Veer_report],
          ['33', _AlarmResource_DistanceIntervalReport],
          ['34', _AlarmResource_CurrentLocationReport],
          ['35', _AlarmResource_TimeIntervalReport],
          ['36', _AlarmResource_TowAlarm],
          ['37', _AlarmResource_RFID],
          ['65', _AlarmResource_SOSCall],
          ['66', _AlarmResource_Input2Call],
          ['67', _AlarmResource_Input3Call],
          ['68', _AlarmResource_Input4Call],
          ['69', _AlarmResource_Input5Call],
          ['70', _AlarmResource_RejectIncomingCall],
          ['71', _AlarmResource_ReportLocationCalling],
          ['72', _AlarmResource_AutoAnswerIncoming],
          ['73', _AlarmResource_Listenin]
];

var EnumAuthType = {
    SMS: 0,
    GPRS: 1,
    Photo: 2
};

function getEventCodeNames(authType, isSMSHeader) {
    var authcodearray = [];
    authcodearray.push(['1', _AlarmResource_SOSButton_Pressed_Input1_Active, false]);
    authcodearray.push(['2', _AlarmResource_ButtonB_Pressed_Input2_Active, false]);
    authcodearray.push(['3', _AlarmResource_ButtonC_Pressed_Input3_Active, false]);
    authcodearray.push(['4', _AlarmResource_Input4_Active, false]);
    authcodearray.push(['5', _AlarmResource_Input5_Active, false]);
    authcodearray.push(['9', _AlarmResource_SOSButton_Released_Input1_InActive, false]);
    authcodearray.push(['10', _AlarmResource_ButtonB_Released_Input2_InActive, false]);
    authcodearray.push(['11', _AlarmResource_ButtonC_Released_Input3_InActive, false]);
    authcodearray.push(['12', _AlarmResource_Input4_InActive, false]);
    authcodearray.push(['13', _AlarmResource_Input5_InActive, false]);
    if (authType != EnumAuthType.Photo) {
        authcodearray.push(['17', _AlarmResource_LowBattery, false]);
        authcodearray.push(['18', _AlarmResource_LowExternalPower, false]);
    }
    authcodearray.push(['19', _AlarmResource_OverSpeed, false]);
    authcodearray.push(['20', _AlarmResource_EnterGeofence, false]);
    authcodearray.push(['21', _AlarmResource_ExitGeofence, false]);
    authcodearray.push(['22', _AlarmResource_ExternalPowerOn, false]);
    if (authType != EnumAuthType.Photo) {
        authcodearray.push(['23', _AlarmResource_ExternalPowerOff, false]);
        authcodearray.push(['24', _AlarmResource_EnterGPSBlindAlarm, false]);
        authcodearray.push(['25', _AlarmResource_ExitGPSBlindAlarm, false]);
        authcodearray.push(['26', _AlarmResource_EnterSleep, false]);
        authcodearray.push(['27', _AlarmResource_ExitSleep, false]);
    }
    authcodearray.push(['28', _AlarmResource_GPSAntennaCut, false]);
    if (authType != EnumAuthType.Photo) {
        authcodearray.push(['29', _AlarmResource_TurnOnAlarm, false]);
    }
    authcodearray.push(['30', _AlarmResource_Impact, false]);
    if (authType == EnumAuthType.GPRS) {
        authcodearray.push(['31', _AlarmResource_HeartbeatReport, false]);
        authcodearray.push(['32', _AlarmResource_Veer_report, false]);
    }
    if (authType != EnumAuthType.Photo) {
        authcodearray.push(['33', _AlarmResource_DistanceIntervalReport, false]);
        //authcodearray.push(['34', _AlarmResource_CurrentLocationReport, false]);
    }
    //if((authType == EnumAuthType.GPRS) || isSMSHeader )
    //    authcodearray.push(['35', _AlarmResource_TimeIntervalReport,false]);
    authcodearray.push(['36', _AlarmResource_TowAlarm, false]);
    if (authType != EnumAuthType.SMS)
        authcodearray.push(['37', _AlarmResource_RFID, false]);
    if (typeof (showFuelDown) != 'undefined') {
        if(showFuelDown)
            authcodearray.push(['54', _TrackerMain_FuelDown, false]);
    }
    if ((authType == EnumAuthType.SMS) && (!isSMSHeader)) {
        authcodearray.push(['65', _AlarmResource_SOSCall, false]);
        authcodearray.push(['66', _AlarmResource_Input2Call, false]);
        authcodearray.push(['67', _AlarmResource_Input3Call, false]);
        authcodearray.push(['68', _AlarmResource_Input4Call, false]);
        authcodearray.push(['69', _AlarmResource_Input5Call, false]);
        authcodearray.push(['70', _AlarmResource_RejectIncomingCall, false]);
        authcodearray.push(['71', _AlarmResource_ReportLocationCalling, false]);
        authcodearray.push(['72', _AlarmResource_AutoAnswerIncoming, false]);
        authcodearray.push(['73', _AlarmResource_Listenin, false]);
    }
    return authcodearray;
}

function createEventCodeStore(authType, isSMSHeader) {
    var darray = getEventCodeNames(authType, isSMSHeader);
    var sto = new Ext.data.ArrayStore({
        fields: ['valueid', 'val', { name: 'choosed', type: 'bool'}],
        data: darray
    });
    return sto;
}

/**********GB区域设置***********/
Ext.ms02data.areatype = [
    ['0', _GB_Circle],
    ['1', _GB_Rectangle],
    ['2', _GB_Polygon],
    ['3', _GB_Route]
]

Ext.ms02data.areacontrol = [
    ['0', '更新区域'],
    ['1', '追加区域'],
    ['2', '修改区域'],
    ['3', '删除区域']
]
Ext.ms02data.areaproperty = [
    ['0', '根据时间'],
    ['1', '限速'],
    ['2', '进区域报警给驾驶员'],
    ['3', '进区域报警给平台'],
    ['4', '出区域报警给驾驶员'],
    ['5', '出区域报警给平台']
]
/**********GB区域设置***********/

Ext.ms02data.buttonvalue = [
    ['0', _TrackerMain_SOSButtonInput1],
    ['1', _TrackerMain_BButtonInput2],
    ['2', _TrackerMain_CButtonInput3]
];

Ext.ms02data.movementvalue = [
    ['0', _TrackerMain_Off],
    ['1', '30m'],
    ['2', '50m'],
    ['3', '100m'],
    ['4', '200m'],
    ['5', '300m'],
    ['6', '500m'],
    ['7', '1000m'],
    ['8', '2000m']
];

Ext.ms02data.onoffvalue = [
    ['0', _TrackerMain_On],
    ['1', _TrackerMain_Off]
];

Ext.ms02data.offonvalue = [
    ['0', _TrackerMain_Off],
    ['1', _TrackerMain_On]

];

Ext.ms02data.yesnovalue = [
    ['0', _TrackerMain_Yes],
    ['1', _TrackerMain_No]
];

Ext.ms02data.noyesvalue = [
    ['0', _TrackerMain_No],
    ['1', _TrackerMain_Yes]
    
];


Ext.ms02data.belowvalue = [
    ['0', _TrackerMain_Below10kmh],
    ['1', _TrackerMain_Below20kmh]
];

Ext.ms02data.sleepvalue = [
    ['0', _TrackerMain_Off],
    ['1', _TrackerMain_Level + ' 1'],
    ['2', _TrackerMain_Level + ' 2'],
    ['3', _TrackerMain_Level + ' 3']
];

Ext.ms02data.outputvalue = [
    ['0', _TrackerMain_Normal],
    ['1', _TrackerMain_CutOff],
    ['2', _TrackerMain_Remain]
];

Ext.ms02data.GPRSValue = [
    ['0', _TrackerMain_Off],
    ['1', 'TCP'],
    ['2', 'UDP']
];

Ext.ms02data.gprsmessagetype = [
    ['0', _TrackerMain_NormalMessage],
    ['1', _TrackerMain_UrgentMessage]
];

Ext.ms02data.eastwestvalue = [
    ['E', 'E'],
    ['W', 'W']
];

Ext.ms02data.northsouthvalue = [
    ['N', 'N'],
    ['S', 'S']
];

Ext.ms02data.eventtype = [
    ['0', _TrackerMain_AutoEventReport],
    ['1', _TrackerMain_EventNeedConfirmBack]
];

Ext.ms02data.buttonpressrelease = [
    ['0',_TrackerMain_CancelPressAlarm],
    ['1', _TrackerMain_AlarmWhenPressed],
    ['2', _TrackerMain_AlarmWhenReleased],
    ['3', _TrackerMain_AlarmWhenPressedOrReleased]
];



var clearrecordstore = createSimpleStore('valueid', 'val', [
            ['1', _TrackerMain_Odometer],
            ['2', _TrackerMain_RunTime],
            ['3', _TrackerMain_Odometer + "&" + _TrackerMain_RunTime]
        ]);

var buttonpressreleasestore = createSimpleStore('valueid', 'val', Ext.ms02data.buttonpressrelease);
var cmdmodelstore = createSimpleStore('modelid', 'text', Ext.ms02data.commandmodels);
var cmdstore = createSimpleStore('cmdid', 'text', Ext.ms02data.gprscommands);
var cmdledstore = createSimpleStore('cmdid', 'text', Ext.ms02data.ledcommands);
var cmdmt88store = createSimpleStore('cmdid', 'text', Ext.ms02data.mt88commands);
//var cmdtzonestore = createSimpleStore('cmdid', 'text', Ext.ms02data.tzonecommands);
//var cmdgbstore = new Ext.data.ArrayStore({
//    fileds:['cmdid','text'],
//    data: Ext.ms02data.gbcommands
//});

var outputstore = createSimpleStore('valueid', 'val', Ext.ms02data.outputvalue);
var butstore = createSimpleStore('valueid', 'val', Ext.ms02data.buttonvalue);
var speedstore = createSimpleStore('valueid', 'val', null);
var movementstore = createSimpleStore('valueid', 'val', Ext.ms02data.movementvalue);
var onoffstore = createSimpleStore('valueid', 'val', Ext.ms02data.onoffvalue);
var offonstore = createSimpleStore('valueid', 'val', Ext.ms02data.offonvalue);
var yesnostore = createSimpleStore('valueid', 'val', Ext.ms02data.yesnovalue); //yes=1,no =0
var noyesstore = createSimpleStore('valueid', 'val', Ext.ms02data.noyesvalue); //no=1,yes=0
var belowstore = createSimpleStore('valueid', 'val', Ext.ms02data.belowvalue);
var sleepstore = createSimpleStore('valueid', 'val',  Ext.ms02data.sleepvalue);
var eastweststore = createSimpleStore('valueid', 'val', Ext.ms02data.eastwestvalue);
var northsouthstore = createSimpleStore('valueid', 'val',  Ext.ms02data.northsouthvalue);
var eventtypestore =createSimpleStore('valueid', 'val',  Ext.ms02data.eventtype);
var gprsstore = createSimpleStore('valueid', 'val', Ext.ms02data.GPRSValue);
var gprsmessagestore = createSimpleStore('valueid', 'val', Ext.ms02data.gprsmessagetype);

var smartsleepmodestore = createSimpleStore('valueid', 'val', [
        ['0', _TrackerMain_CancelSleepMode],
        ['1', _TrackerMain_NormalSleepMode],
        ['2', _TrackerMain_DeepSleepMode]
    ]);

var extprintinfostore = createSimpleStore('valueid', 'val', [
    ['A', _Ext_TrackingReport],
    ['B', _Ext_DeviceName],
    ['C', _Ext_SerialNo],
    ['D', _Ext_VINNo],
    ['E', _Ext_CarLabel],
    ['F', _Ext_DriverName],
    ['G', _Ext_DrivingLicenseNo]
]);

var delbufstore = createSimpleStore('valueid', 'val', [
            ['1', "SMS"],
            ['2', "GPRS"],
            ['3', "SMS&GPRS"]
        ]);

/***********国标存储***************/
var gbtextsignstore = createSimpleStore('valueid', 'val', [
            ['0', "紧急"],
            ['2', "终端显示器显示"],
            ['3', "TTS播报"],
            ['4', "广告屏显示"]
        ]);

var gbeventsettypestore =createSimpleStore('valueid', 'val', [
            ['0', "删除终端现有所有事件"],
            ['1', "更新事件"],
            ['2', "追加事件"],
            ['3', "修改事件"],
            ['4', "删除特定事件"]
        ]);

var gbquestionsignstore = createSimpleStore('valueid', 'val', [
            ['0', "紧急"],
            ['3', "终端TTS播读"],
            ['4', "广告屏显示"]
        ]);

var gbmenusettypestore = createSimpleStore('valueid', 'val', [
            ['0', "删除终端全部信息项"],
            ['1', "更新菜单"],
            ['2', "追加菜单"],
            ['3', "修改菜单"]
        ]);
        
var gbmessagetypestore = createSimpleStore('valueid', 'val', [ ['0', "普通"],['1', "紧急"]]);
var gbphonecallsignstore = createSimpleStore('valueid', 'val', [['0', "普通电话"], ['1', "监听"]]);
var gbphonebooksettypestore = createSimpleStore('valueid', 'val', [
            ['0', "删除终端上所以存储的联系人"],
            ['1', "更新电话本"],
            ['2', "追加电话本"],
            ['3', "修改电话本"]]);


var gbphonebooksignstore = createSimpleStore('valueid', 'val', [ 
    ['1',"呼入"],['2', "呼出"],['3', "呼入/呼出"]]);

var gbcollectcommandstore =  createSimpleStore('valueid', 'val', [ 
            ['01', "采集驾驶员代码及对应的机动车驾驶证号码"],
            ['02', "采集记录仪的实时时钟"],
            ['03', "采集最近360h内的累计行驶里程数据"],
            ['04', "采集记录仪中的车辆特征系数"],
            ['05', "采集最近360h内的行驶速度数据"],
            ['06', "采集车辆VIN号、车牌号码、车辆分类"],
            ['07', "采集记录仪中事故疑点数据"],
            ['08', "采集最近2个日历天内的累计行驶里程"],
            ['09', "采集最近2个日历天内的行驶速度数据"],
            ['11', "采集最近2个日历天内的同一驾驶员连续驾驶时间超过3个小时的所有记录数据"]
        ]);

var gbsendlogstore = createSimpleStore('valueid', 'val', [ 
            ['81', "驾驶员代码、驾驶证号码"],
            ['82', "车辆VIN号、车牌号、分类"],
            ['C2', "北京时间时钟"],
            ['C3', "车辆特征系数"]
        ]);

var gbshootcommandstore =createSimpleStore('valueid', 'val', [ 
            ['0', "停止拍摄"],
            ['0xFFFF', "录像"],
            ['AAA', "拍照张数"]
        ]);

var gbshootsavesignstore = createSimpleStore('valueid', 'val', [ 
            ["1","保存"],["0","实时上传"]]);

var gbshootresolutionstore = createSimpleStore('valueid', 'val', [ 
            ["1", "320*240"],
            ["2", "640*480"],
            ["3", "800*600"],
            ["4", "1024*768"],
            ["5", "176*144;[Qcif]"],
            ["6", "352*288;[Cif]"],
            ["7", "704*288;[HALF D1]"],
            ["8", "704*576;[D1]"]
        ]);

var gbmediatypestore = createSimpleStore('valueid', 'val', [ 
            ["0", "图像"],
            ["1", "音频"],
            ["2", "视频"]
        ]);

var gbmediaeventcodestore = createSimpleStore('valueid', 'val', [ 
            ["0", "平台下发指令"],
            ["1", "定时动作"],
            ["2", "抢劫报警触发"],
            ["3", "碰撞侧翻报警触发"]
        ]);

var gbmediadeletesignstore = createSimpleStore('valueid', 'val', [ 
          ["0", "保留"],
          ["1", "删除"]
        ]);
var gbvoicerecordcommandstore = createSimpleStore('valueid', 'val', [ 
    ["0", "停止录音"],
    ["1", "开始录音"]]);

var gbvoicerecordsavesignstore = createSimpleStore('valueid', 'val', [ 
    ["0", "实时上传"],
    ["1", "保存"]
    ]);

var gbvoicefrequencystore = createSimpleStore('valueid', 'val', [ 
    ["0", "8K"],
    ["1", "11K"],
    ["2", "23K"],
    ["3", "32K"]
    ]);
    
var gbcontroltrackercmdstore = createSimpleStore('valueid', 'val', [
            ["1", "无线升级"],
            ["2", "控制终端连接指定服务器"],
            ["3", "终端关机"],
            ["4", "终端复位"],
            ["5", "终端恢复出厂设置"],
            ["6", "关闭数据通信"],
            ["7", "关闭所有无线通信"]
        ]);



/****************************************/
function createSimpleStore(valueid, displayid, storeArray) {
    if (storeArray != null)
        return new Ext.data.ArrayStore({
            fields: [valueid, displayid],
            data: storeArray
        });
    else
        return new Ext.data.ArrayStore({
            fields: [valueid, displayid]
        });
}


function getIndexStore(begin, max) {
    var d = [];
    var i;
    for (i = begin; i <= max; i++) {
        var obj = [];
        obj.push(i.toString());
        obj.push(i.toString());
        d.push(obj);
    }
    var dstore = new Ext.data.ArrayStore({
        fields: ['valueid', 'val'],
        data: d
    });
    return dstore;
}
//创建下拉列表
function createComboBoxForCommand(canedit, label, store, valueField, displayField, typeAhead,
 forceSelection, selectOnFocus, width, tpl, selectFn) {
    var combo = new Ext.form.ComboBox({
        editable: canedit,
        hideLabel: label == "" ? true : false,
        labelStyle: 'padding-left:10px;text-align:left',
        fieldLabel: label,
        store: store,
        valueField: valueField,
        displayField: displayField,
        typeAhead: typeAhead,
        mode: 'local',
        forceSelection: forceSelection,
        triggerAction: 'all',
        emptyText: '',
        selectOnFocus: selectOnFocus,
        width: width,
        tpl: tpl
    });
    combo.addListener('select', selectFn);
    return combo;
}

//创建面板
function createPanelForCommand(id, layout, border, width, height, labelWidth, items, columns, buttonAlign, style, autoScroll) {
    var config = new Object();
    if (style) config.style = style;
    if (id) config.id = id;
    if (border != null || border != undefined)
        config.border = border;
    if (layout) {
        config.layout = layout;
        if (layout == "table") {
            config.layoutConfig = new Object();
            if (columns)
                config.layoutConfig.columns = columns;
        }
    }
    if (width) config.width = width;
    if (height) config.height = height;
    else config.autoHeight = true;
    if (labelWidth) config.labelWidth = labelWidth;
    if (items) config.items = items;
    if (buttonAlign) config.buttonAlign = buttonAlign;
    if (autoScroll) config.autoScroll = autoScroll;
    return new Ext.Panel(config);
}


var commandmodel = getCookie("CommandModel");
var cmbcommandmodel = createComboBoxForCommand(false, _TrackerMain_Model, cmdmodelstore, 'modelid', 'text', false, true, true, 280, null,
function(combo, record, index) {
    commandmodel = parseInt(record.get('modelid'));
    setCookie("CommandModel", index, 365);
    if (showSMS) {

        if (gprsorsmsgroup.getValue().inputValue == 0) {
            loadCommandbyModel(index);
        }
        else {
            loadSmsCommandbyModel(index);
        }
    }
    else
        loadCommandbyModel(index);
});


var gprsorsmsgroup = new Ext.form.RadioGroup({
    columns: 'auto',
    fieldLabel: _TrackerMain_SendType,
    width: 280,
    labelStyle: 'padding-left:10px;text-align:left',
    items: [{
        name: 'sendtype_ra',
        inputValue: 0,
        boxLabel: 'GPRS',
        checked: true
    }, {
        name: 'sendtype_ra',
        inputValue: 1,
        boxLabel: 'SMS'
    }
]
});



var cmbcommand = createComboBoxForCommand(false, _TrackerMain_Command, cmdstore, 'cmdid', 'text',
false, true, true, 280,
'<tpl for="."><div class="x-combo-list-item" ext:qtitle="" ext:qtip="{text}">{text}</div></tpl>',
function() {
    var cmdtext = cmbcommand.getRawValue();
    choosecommandandshowparams(cmdtext);
});

cmbcommandmodel.setValue(commandmodel);

var cmdledcommand = createComboBoxForCommand(false, _CommandExpression_LED, cmdledstore, 'cmdid', 'text',false, true, true, 280,
    '<tpl for="."><div class="x-combo-list-item" ext:qtitle="" ext:qtip="{text}">{text}</div></tpl>',
function() {
    var cmdtext = cmdledcommand.getRawValue();
    chooseledcommandandshowparams(cmdtext);
});


function loadCommandbyModel(model) {
    if (model == 0)
        cmdstore.loadData(Ext.ms02data.gprscommands);
    else if (model == 2)
        cmdstore.loadData(Ext.ms02data.gbcommands);
//    else if (model == 3)
//        cmdstore.loadData(Ext.ms02data.tzonecommands);
    else
        cmdstore.loadData(Ext.ms02data.mt88commands);
    cmbcommand.setValue('0');
    disableAllParamPanel();
}

loadCommandbyModel(commandmodel);


function loadSmsCommandbyModel(model) {
    if (model != 1)
        cmdstore.loadData(Ext.ms02data.smsgtdata);
    else
        cmdstore.loadData(Ext.ms02data.smsmt88data);
    cmbcommand.setValue('0');
    disableAllParamPanel();
}


gprsorsmsgroup.on('change', function(group, radio) {
    var value = radio.inputValue;
    if (value == 0) {
        loadCommandbyModel(commandmodel);
    }
    else {
        loadSmsCommandbyModel(commandmodel);
    }
});

var panelcmdlist = createPanelForCommand(null, 'form', false, 370, 85, 70, [cmbcommandmodel, cmbcommand], null, null, 'padding-top:10px');


if (showSMS)
    panelcmdlist.insert(1, gprsorsmsgroup);


var txtparams1;
var txtparams2;
var txtparams3;
var txtparams4;
var txtparams5;
var txtparams6;
var cmbparams1;
var cmbparams2;
var cmbparams3;
var cmbparams4;
var cmbparams5;
var cmbparams6;
var lblunit1;
var lblunit2;
var lblunit3;
var lblunit4;
var lblunit5;
var lblunit6;

var radiogroupparam1;
/**************国标变量***************/
var paramsArray = new Array(); //参数集合
var routeWidth = 50;
/*************************************/
/**************国标方法***************/
function showOrHideGbDefaultParams(isShow) {
    Ext.each(panelgbareadefaultparams.items.items, function(item, index) {
        if (index >= 2) {
            if (isShow) item.show();
            else item.hide();
        }
    });
}
/*************************************/
var day = new Date();
var today = day.getFullYear() + '-' + (day.getMonth() + 1) + '-' + day.getDate();


function createNewParamDateTimeField() {

    var fromDateEditor = new Ext.form.DateField({
        id:'datetime_gb_start_date',
        renderer: Ext.util.Format.dateRenderer('Y-m-d'),
        format: 'Y-m-d',
        fieldLabel: _Ext_StartDateTime,
        value: today
    });
    var fromTimeEditor = new Ext.form.TimeField({
    id: 'datetime_gb_start_time',
        value:"00:00",
        format: 'H:i',
        width: 70
    });
    var toDateEditor = new Ext.form.DateField({
    id: 'datetime_gb_end_date',
        renderer: Ext.util.Format.dateRenderer('Y-m-d'),
        format: 'Y-m-d',
        fieldLabel: _Ext_StopDateTime,
        value: today
    });
    var toTimeEditor = new Ext.form.TimeField({
        id: 'datetime_gb_end_time',
        value: "23:59",
        format: 'H:i',
        width: 70
    });
    var datePanel = createPanelForCommand('datepanel', 'form', false, 200, null, 70,
    [fromDateEditor, toDateEditor]);
    var timePanel = createPanelForCommand('timepanel', 'form', false, 100, null, 10,
    [fromTimeEditor, toTimeEditor]);
    var dateTimePanel = createPanelForCommand('datetimepanel', 'table', false, 300, null, 70, [datePanel, timePanel], 2, null, 'padding-left:10px;padding-top:5px');
    return dateTimePanel;
}

function createNewParamCmbField(pstore, labelcap, etext) {
    var pcmbfield = new Ext.form.ComboBox({
        editable: false,
        labelStyle: 'padding-top:6px;padding-left:10px;text-align:left',
        fieldLabel: labelcap,
        store: pstore,
        valueField: 'valueid',
        displayField: 'val',
        typeAhead: false,
        mode: 'local',
        forceSelection: true,
        triggerAction: 'all',
        //emptyText:_TrackerMain_SelectACommand,
        selectOnFocus: true,
        width: 150
    });
    if (etext == null)
        pcmbfield.emptyText = _TrackerMain_SelectACommand;
    else
        pcmbfield.emptyText = etext;
    return pcmbfield;
}

function createNewParamRadioGroup(grouplabel, itemlabels, width,name) {
    var items = new Array();
    for (var i = 0; i < itemlabels.length; i++) {
        var checked = false;
        if (i == 0)
            checked = true;
        items.push({
            name: name,
            boxLabel: itemlabels[i],
            checked: checked,
            inputValue: i
        });
    }
    return new Ext.form.RadioGroup({
        columns: 'auto',
        fieldLabel: grouplabel,
        width: width,
        labelStyle: 'padding-left:10px;text-align:left',
        items: items
    });
}

function createNewMultiParamCmbField(pstore, labelcap, etext) {
    var pcmbfield = new Ext.ux.form.CheckboxCombo({
        //editable: false,
        labelStyle: 'padding-top:6px;padding-left:10px;text-align:left',
        fieldLabel: labelcap,
        store: pstore,
        valueField: 'valueid',
        displayField: 'val',
        //typeAhead: false,
        mode: 'local',
        //forceSelection: true,
        //triggerAction: 'all',
        //emptyText:_TrackerMain_SelectACommand,
        //selectOnFocus: true,
        width: 150
    });
    if (etext == null)
        pcmbfield.emptyText = _TrackerMain_SelectACommand;
    else
        pcmbfield.emptyText = etext;
    return pcmbfield;
}

function createNewParamNumberField(labelcap, maxlength,readOnly,id) {
    var config = {
        fieldLabel: labelcap,
        maxLength: maxlength,
        labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
        width: 120,
        readOnly: readOnly,
        allowBlank: false
    };
    if (Ext.isDefined(id))
        config.id = id;
    var pnumberfield = new Ext.form.NumberField(config);
    return pnumberfield;
}

function createNewParamTextField(labelcap, maxlength,readOnly,id,name) {
    var config = {
        fieldLabel: labelcap,
        maxLength: maxlength,
        labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
        width: 120,
        value:"",//这个默认值
        readOnly: readOnly
    };
    if (Ext.isDefined(id))
        config.id = id;
    if (Ext.isDefined(name))
        config.name = name;
    var pfield = new Ext.form.TextField(config);
    if (maxlength)
        pfield.maxLength = maxlength;
        
    return pfield;
}

function createNewParamTextArea(labelcap, maxlength, readOnly, id, name) {
    var config = {
        fieldLabel: labelcap,
        maxLength: maxlength,
        labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
        height: 100,
        width: 200,
        value: "",
        readOnly: readOnly
    };
    if (Ext.isDefined(id))
        config.id = id;
    if (Ext.isDefined(name))
        config.name = name;
    var pfield = new Ext.form.TextArea(config);
    if (maxlength)
        pfield.maxLength = maxlength;

    return pfield;
}

function createNewParamDate(labelcap, readOnly,id,name,format){
     var config = {
        fieldLabel: labelcap,
        labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
        height: 100,
        width: 150,
        value: "",
        readOnly: readOnly,
        format:'m-d'
    };
    if (Ext.isDefined(id))
        config.id = id;
    if (Ext.isDefined(name))
        config.name = name;
    if(Ext.isDefined(format))
        config.format =format;
    var pfield = new Ext.form.DateField(config);
    return pfield;
}

function createNewParamTime(labelcap,readOnly,id,name,format){
    var config = {
        fieldLabel: labelcap,
        labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
        height: 100,
        width: 150,
        value: "",
        readOnly: readOnly,
        format:'H:i'
    };
    if (Ext.isDefined(id))
        config.id = id;
    if (Ext.isDefined(name))
        config.name = name;
    if(Ext.isDefined(format))
        config.format =format;
    var pfield = new Ext.form.TimeField(config);
    return pfield;
}

function createNewParamUnitLabel(unitcap) {
    var punit = new Ext.form.Label({
        //hideLabel:true,
        fieldLabel: unitcap,
        labelSeparator: "",
        labelStyle: 'padding-top:6px;text-align: left',
        width: 50
    });
    return punit;
}

var EnumParamFieldType = {
    TextField: 1,
    NumberField: 2,
    ComboBoxField: 3,
    MultiComboBoxField: 4,
    TextArea: 5,
    Date: 6,
    Time: 7
};

function createNewParamAndShow(paramfieldtype, captext, maxlen, unittext, cmbstore,name,id) {
    var r;
    if (unittext.length == 0)
        unittext = " "; //give a space if text is empty
    var lblunit = createNewParamUnitLabel(unittext);
    if (paramfieldtype == EnumParamFieldType.TextField)
        r = createNewParamTextField(captext, maxlen,false,null,name);
    else if (paramfieldtype == EnumParamFieldType.NumberField)
        r = createNewParamNumberField(captext, maxlen);
    else if (paramfieldtype == EnumParamFieldType.ComboBoxField) {
        r = createNewParamCmbField(cmbstore, captext);
        r.setValue(cmbstore.getAt(0).get(r.valueField));
    }
    else if (paramfieldtype == EnumParamFieldType.MultiComboBoxField) {
        r = createNewMultiParamCmbField(cmbstore, captext);
    }
    else if (paramfieldtype == EnumParamFieldType.TextArea) {
        r = createNewParamTextArea(captext, maxlen);
    }
    else if(paramfieldtype == EnumParamFieldType.Date){
        r = createNewParamDate(captext,false,id);
    }
    else if(paramfieldtype == EnumParamFieldType.Time){
        r = createNewParamTime(captext,false,id);
    }
    if (!Ext.isEmpty(name))
        r.name = name;
    panelparamscolumn1.add(r);
    panelparamscolumn2.add(lblunit);
    return r;
}

function reshowparams() {
    disableAllParamPanel();
    panelparams.show();
    btnAddNewAnswer.hide();
    btnRemoveAnswer.hide();
    btnAddNewContact.hide();
    btnRemoveContact.hide();
}

function redolayoutparams() {
    panelparamscolumn1.doLayout();
    panelparamscolumn2.doLayout();
    panelparams.setHeight(panelcommand.getHeight()-200);
    //butsendcommand.enable();
}

var panelgbareadefaultparams = createPanelForCommand('panelgbareadefaultparams', 'form', false, 320, null, 70);
var panelgbareaotherparams = createPanelForCommand('panelgbareaotherparams', 'form', false, 320, null, 70, null, null, null, null, true);
var panelgbareaparams = createPanelForCommand('panelgbareaparams', 'form', false, 380,190, 70,[panelgbareadefaultparams, panelgbareaotherparams], null, null, null, true);

var panelparamscolumn1 = new Ext.Panel({
    id: 'panelparamscolumn1',
    layout: 'form',
    border: false,
    width: 290,
    labelWidth: 70,
    autoHeight: true,
    //boxMaxHeight: 300,
    //autoScroll: true,
    items: []
});

var panelparamscolumn2 = new Ext.Panel({
    id: 'panelparamscolumn2',
    layout: 'form',
    border: false,
    width: 90,
    autoHeight: true
});
//var panelparamscolumn1 = createPanelForCommand('panelparamscolumn1', 'form', false, 300, 195, 70, null,null,null,null,true);
//var panelparamscolumn2 = createPanelForCommand('panelparamscolumn2', 'form', false, 90, 195);
var panelparams = createPanelForCommand('panelparams', 'table', false, 380,300,null,[panelparamscolumn1, panelparamscolumn2],2,null,null,true);

//**************** Begin Rectangel GeoFence****************
var chkgeoturnoff = new Ext.form.Checkbox({
    id: 'chkgeoturnoff',
    hideLabel: true,
    boxLabel: _TrackerMain_TurnOff
});

var panelgeoparamsrow1column1 = createPanelForCommand('panelgeoparamsrow1column1', 'form', false, 90, null, null, chkgeoturnoff);

var radgeoinalarm = new Ext.form.Radio({
    id: 'radgeoinalarm',
    name: 'alarmtype',
    hideLabel: true,
    boxLabel: _TrackerMain_InAlarm,
    checked: true
});

var panelgeoparamsrow1column2 = createPanelForCommand('panelgeoparamsrow1column2','form',false,90,null,null,radgeoinalarm);

var radgeooutalarm = new Ext.form.Radio({
    id: 'radgeooutalarm',
    name: 'alarmtype',
    hideLabel: true,
    boxLabel: _TrackerMain_OutAlarm,
    checked: false
});

var panelgeoparamsrow1column3 = createPanelForCommand('panelgeoparamsrow1column3', 'form', false, 90, null, null, radgeooutalarm);

function degreeToGPS(absdegree, degreelen) {
    var d = Math.floor(absdegree);
    var f = (absdegree - d) * 60;
    var gps = String.leftPad(d.toString(), degreelen, "0") + String.leftPad(Ext.util.Format.number(f, "0.0000"), 7, "0");
    return gps;
}

var butdrawgeo = new Ext.ux.ImageButton({
    id: 'butdrawgeo',
    imgPath: 'Content\images\drawgeo.png',
    imgWidth: 16,
    imgHeight: 16,
    height: 16,
    width: 16,
    tooltip: _TrackerMain_DrawGeo,
    handler: function() {
        var inout;
        if (radgeooutalarm.checked)
            inout = 0;
        else
            inout = 1;
        if (imap != null) {
            imap.beginDrawGeoFence(inout);
            imap.FnGeoFenceCallBack = function(y1, x1, y2, x2) {
                var xmin = x1 < x2 ? x1 : x2;
                var xmax = x1 > x2 ? x1 : x2;
                var ymin = y1 < y2 ? y1 : y2;
                var ymax = y1 > y2 ? y1 : y2;
                //format 1 = Ext.util.Format.number(Math.abs(xmin),"0.000000"),10,"0"

                txtLowerLeftX.setValue(degreeToGPS(Math.abs(xmin), 3));
                txtLowerLeftY.setValue(degreeToGPS(Math.abs(ymin), 2));
                txtUpperRightX.setValue(degreeToGPS(Math.abs(xmax), 3));
                txtUpperRightY.setValue(degreeToGPS(Math.abs(ymax), 2));
                cmbEWLowerLeft.setValue(xmin > 0 ? 'E' : 'W');
                cmbEWUpperRight.setValue(xmax > 0 ? 'E' : 'W');
                cmbNSLowerLeft.setValue(ymin > 0 ? 'N' : 'S');
                cmbNSUpperRight.setValue(ymax > 0 ? 'N' : 'S');
            };
        }
    }
});

var panelgeoparamsrow1column4 = createPanelForCommand('panelgeoparamsrow1column4','form',false,20,20,null,butdrawgeo);


var panelgeoparamsrow1 = createPanelForCommand('panelgeoparamsrow1','table',false,380,null,null,
[panelgeoparamsrow1column1, panelgeoparamsrow1column2, panelgeoparamsrow1column3, panelgeoparamsrow1column4],4);


var txtLowerLeftX = new Ext.form.TextField({
    fieldLabel: _TrackerMain_LowerLeftX,
    decimalPrecision: 6,
    maxLength: 11,
    labelStyle: 'padding-top:6px;padding-left:10px;width:90px;text-align: left',
    width: 120
});

var txtLowerLeftY = new Ext.form.TextField({
    fieldLabel: _TrackerMain_LowerLeftY,
    decimalPrecision: 6,
    maxLength: 11,
    labelStyle: 'padding-top:6px;padding-left:10px;width:90px;text-align: left',
    width: 120
});

var txtUpperRightX = new Ext.form.TextField({
    fieldLabel: _TrackerMain_UpperRightX,
    decimalPrecision: 6,
    maxLength: 11,
    labelStyle: 'padding-top:6px;padding-left:10px;width:90px;text-align: left',
    width: 120
});

var txtUpperRightY = new Ext.form.TextField({
    fieldLabel: _TrackerMain_UpperRightY,
    decimalPrecision: 6,
    maxLength: 11,
    labelStyle: 'padding-top:6px;padding-left:10px;width:90px;text-align: left',
    width: 120
});

var panelgeoparamsrow2column1 = createPanelForCommand('panelgeoparamsrow2column1', 'form', false, 250, null, null,
[txtLowerLeftX, txtLowerLeftY, txtUpperRightX, txtUpperRightY]);

var cmbEWLowerLeft = createComboBoxForCommand(false, false, eastweststore, 'valueid', 'val', false, true, true, 40);
var cmbEWUpperRight =createComboBoxForCommand(false, false, eastweststore, 'valueid', 'val', false, true, true, 40);
var cmbNSLowerLeft = createComboBoxForCommand(false, false, northsouthstore, 'valueid', 'val', false, true, true, 40);
var cmbNSUpperRight = createComboBoxForCommand(false, false, northsouthstore, 'valueid', 'val', false, true, true, 40);

var panelgeoparamsrow2column2 = createPanelForCommand('panelgeoparamsrow2column2', 'form', false, 50, null, null,
[cmbEWLowerLeft, cmbNSLowerLeft, cmbEWUpperRight, cmbNSUpperRight]);


var panelgeoparamsrow2 = createPanelForCommand('panelgeoparamsrow2','table',false,300,null,null,
[panelgeoparamsrow2column1, panelgeoparamsrow2column2],2);
var panelgeoparams = createPanelForCommand('panelgeoparams', 'form', false, null, null, null, [panelgeoparamsrow1, panelgeoparamsrow2]);

//******************************End Rectangle GeoFence*************************
//******************************Begin Radius GeoFence**************************
var cmbCircleGFenceIndex = createNewParamCmbField(getIndexStore(1, 8), _TrackerMain_Index);
cmbCircleGFenceIndex.setWidth(120);
cmbCircleGFenceIndex.setValue(1);

var chkCircleGFenceInAlarm = new Ext.form.Checkbox({
    labelStyle: 'padding-left:10px;text-align:left',
    fieldLabel: _TrackerMain_InAlarm
    //boxLabel: _TrackerMain_InAlarm
});

var chkCircleGFenceOutAlarm = new Ext.form.Checkbox({
    labelStyle: 'padding-left:10px;text-align:left',
    fieldLabel: _TrackerMain_OutAlarm
    //boxLabel: _TrackerMain_OutAlarm
});

var butdrawcgeofence = new Ext.Button({
    text: _TrackerMain_DrawGeo,
    style: 'margin-left:110px',
    handler: function() {
        var inout;
        if (chkCircleGFenceInAlarm.checked && chkCircleGFenceOutAlarm.checked)
            inout = 2;
        else if (chkCircleGFenceInAlarm.checked)
            inout = 1;
        else if (chkCircleGFenceOutAlarm.checked)
            inout = 0;
        if (imap != null) {
            imap.beginDrawCircleGeoFence(inout);
            imap.FnCircleGeoFenceCallBack = function(lat, lng, radius) {
                txtCircleGeoFenceLati.setValue(lat.toFixed(6));
                txtCircleGeofenceLongi.setValue(lng.toFixed(6));
                txtCircleRadius.setValue(radius.toFixed(0));
            };
        }
    }
});

var txtCircleGeoFenceLati = createNewParamNumberField(_TrackerMain_Latitude, 10);
txtCircleGeoFenceLati.decimalPrecision = 6;

var txtCircleGeofenceLongi = createNewParamNumberField(_TrackerMain_Longitude, 11);
txtCircleGeofenceLongi.decimalPrecision = 6;

var txtCircleRadius = createNewParamNumberField(_TrackerMain_Radius, 10);
txtCircleRadius.decimalPrecision = 0;

var panelcirclegeoparams = createPanelForCommand('panelcirclegeoparams', 'form', false, null, null, null,
[cmbCircleGFenceIndex, chkCircleGFenceInAlarm, chkCircleGFenceOutAlarm, butdrawcgeofence, txtCircleGeoFenceLati, txtCircleGeofenceLongi, txtCircleRadius]);

/************************************End Circle GeoFence***************************/
var butsendcommand = new Ext.Button({
    id: 'sendcommand',
    disabled: isdemoaccount == 'True' ? true : false,
    text: _TrackerMain_Send,
    handler: function() {
        sendCommand();
    }
});


var panelallcommand = createPanelForCommand('panelallcommand', 'form', false, 390,null,70, panelcmdlist, null, 'center');
//var panelledcommand = createPanelForCommand('panelledcommand', 'form', false, 375, null, null, panelledcmdlist,null,'center');

panelallcommand.add(cmdledcommand);
panelallcommand.add(panelparams);
panelallcommand.add(panelgeoparams);
panelallcommand.add(panelcirclegeoparams);
panelallcommand.add(panelgbareaparams);
panelallcommand.addButton(butsendcommand);


var btnAddNewAnswer = new Ext.Button({
    text: '添加新答案',
    handler: function() {
        var myanswers = panelparamscolumn1.find('name', "txt_question_for_answer");
        if (myanswers.length >= 8) return;
        btnRemoveAnswer.setDisabled(false);
        createNewParamAndShow(EnumParamFieldType.TextField, "答案内容", 1024, "", null, "txt_question_for_answer");
        panelparamscolumn1.doLayout();
    }
});
var btnRemoveAnswer = new Ext.Button({
    text: '移除答案',
    disabled: true,
    handler: function() {
        var myanswers = panelparamscolumn1.find('name', "txt_question_for_answer");
        if (myanswers.length == 2)
            this.setDisabled(true);
        var lastItem = myanswers[myanswers.length - 1];
        panelparamscolumn1.remove(lastItem, true);
        Ext.destroy(lastItem);
        panelparamscolumn1.doLayout();
    }
});

var btnAddNewContact = new Ext.Button({
    text: '添加新联系人',
    handler: function() {
        var b1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "标志", 0, "", gbphonebooksignstore,"cmb_contact_flag");
        var b2 =createNewParamAndShow(EnumParamFieldType.TextField, "电话号码", 255, "", null,"txt_contact_phonenumber");
        b2.allowBlank = true;
        var b3 = createNewParamAndShow(EnumParamFieldType.TextField, "联系人", 255, "", null,"txt_contact_username");
        b3.allowBlank = true;
        panelparamscolumn1.doLayout();
    }
});

var btnRemoveContact = new Ext.Button({
    text: '移除联系人',
    disabled: true,
    handler: function() {
        var myflags = panelparamscolumn1.find('name', "cmb_contact_flag");
        var mynumbers = panelparamscolumn1.find('name', "txt_contact_phonenumber");
        var mynames = panelparamscolumn1.find('name', "txt_contact_username");
        if (myflags.length == 2) {
            this.setDisabled(true);
        }
        var lastflag = myflags[myflags.length - 1];
        var lastnumber = mynumbers[mynumbers.length - 1];
        var lastname = mynames[mynames.length - 1];
        panelparamscolumn1.remove(lastflag, true);
        panelparamscolumn1.remove(lastnumber, true);
        panelparamscolumn1.remove(lastname, true);
        Ext.destroy(lastflag);
        Ext.destroy(lastnumber);
        Ext.destroy(lastname);
        panelparamscolumn1.doLayout();
    }
});

panelallcommand.addButton(btnAddNewAnswer);
panelallcommand.addButton(btnRemoveAnswer);
panelallcommand.addButton(btnAddNewContact);
panelallcommand.addButton(btnRemoveContact);
btnRemoveAnswer.hide();
btnAddNewAnswer.hide();
btnRemoveContact.hide();
btnAddNewContact.hide();
disableAllParamPanel();

function disableAllParamPanel() {
    if (panelparamscolumn1 != null)
        panelparamscolumn1.removeAll();
    if (panelparamscolumn2 != null)
        panelparamscolumn2.removeAll();
    if (panelparams != null)
        panelparams.hide();
    if(cmdledcommand != null)
        cmdledcommand.hide();
    if (panelgeoparams != null)
        panelgeoparams.hide();
    if (panelcirclegeoparams != null)
        panelcirclegeoparams.hide();
    if (panelgbareaparams != null)
        panelgbareaparams.hide();
    txtparams1 = null;
    txtparams2 = null;
    txtparams3 = null;
    txtparams4 = null;
    txtparams5 = null;
    txtparams6 = null;
    cmbparams1 = null;
    cmbparams2 = null;
    cmbparams3 = null;
    cmbparams4 = null;
    cmbparams5 = null;
    cmbparams6 = null;
    lblunit1 = null;
    lblunit2 = null;
    lblunit3 = null;
    lblunit4 = null;
    lblunit5 = null;
    lblunit6 = null;
}

function iniSpeedStore() {
    speedstore.removeAll();
    speedstore.add(new speedstore.recordType({ valueid: '0', val: _TrackerMain_Off }));
    var i;
    for (i = 1; i < 30; i++) {
        var c1 = i.toString();
        var c2 = (i * 10).toString() + ' km/h';
        speedstore.add(new speedstore.recordType({ valueid: c1, val: c2 }));
    }
}

function showOutputControl() {
    cmbparams2 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Output + ' 1', 255, '', outputstore);
    cmbparams2.setValue('2');
    cmbparams3 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Output + ' 2', 255, '', outputstore);
    cmbparams3.setValue('2');
    cmbparams4 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Output + ' 3', 255, '', outputstore);
    cmbparams4.setValue('2');
    cmbparams5 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Output + ' 4', 255, '', outputstore);
    cmbparams5.setValue('2');
    cmbparams6 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Output + ' 5', 255, '', outputstore);
    cmbparams6.setValue('2');
}

var gprssetauthwindow;
var photosetauthwindow;

function showGPRSAuthWindow() {
    if (gprssetauthwindow == null)
        gprssetauthwindow = new GPRSAuthWindow("", _TrackerMain_AllSelected, "FFFFFFFFFFFFFFFF");
    gprssetauthwindow.show();
}

function showPhotoAuthWindow() {

    if (photosetauthwindow == null)
        photosetauthwindow = new GPRSAuthWindow("", _TrackerMain_AllSelected, "0000000000000000", true);
    photosetauthwindow.show();
}

function choosecommandandshowparams(cmdtext) {
    if (cmdtext == _CommandExpression_TrackOnDemand) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_TrackByPresetInterval) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Interval, 2, _TrackerMain_Minutes, null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetGPRSInterval) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Interval, 5, 'X10 ' + _TrackerMain_Seconds, null);
        txtparams1.allowBlank = false;
        txtparams1.maxValue = 65535;
        txtparams1.minValue = 0;
        txtparams1.minText = _Message_MinText + ' 0';
        txtparams1.maxText = _Message_MaxText + ' 65535';
        txtparams1.blankText = _Message_BlankText;

        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_Authorization) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Button, 0, "", butstore);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_T1, 16, "", null);
        txtparams3 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_T2, 16, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetAPN) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, "APN", 32, "", null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_UserName, 32, "", null);
        txtparams3 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_Password, 32, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetIPPort) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_IP, 15, "", null);
        cmbparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Port, 5, "", null);

        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetSMSInitials) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Button, 0, "", butstore);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, "", 16, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetOverSpeed) {
        if (commandmodel == 0) {
            iniSpeedStore();
            reshowparams();
            cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_MaxSpeed, 0, "", speedstore);
            redolayoutparams();
        }
        else {
            reshowparams();
            txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_MaxSpeed, 5, showmiles ? _TrackerMain_MPH : _TrackerMain_KMH, null);
            redolayoutparams();
        }
    }
    else if (cmdtext == _CommandExpression_SetMovementAlarm) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Distance, 0, "", movementstore);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_EnableGPRSTracking) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "", 0, "", gprsstore);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetGeoFence) {
        if (commandmodel == 0) {
            disableAllParamPanel();
            panelgeoparams.show();
            panelgeoparams.doLayout();
            cmbEWLowerLeft.setValue('E');
            cmbEWUpperRight.setValue('E');
            cmbNSLowerLeft.setValue('N');
            cmbNSUpperRight.setValue('N');
        }
        else {
            disableAllParamPanel();
            cmbCircleGFenceIndex.show();
            panelcirclegeoparams.show();
            panelcirclegeoparams.doLayout();
        }
    }
    else if (cmdtext == _CommandExpression_GetIMEI) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_SetGeoFenceCircle) {
        disableAllParamPanel();
        panelcirclegeoparams.show();
        cmbCircleGFenceIndex.hide();
        panelcirclegeoparams.doLayout();
    }
    else if (cmdtext == _CommandExpression_SetExtendedFunctions) {
        reshowparams();
        if (commandmodel == 0) {
            cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_CallForSMS, 0, "", createSimpleStore('valueid', 'val', Ext.ms02data.offonvalue));
            cmbparams2 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_SMSFormat, 0, "", createSimpleStore('valueid', 'val', [
            ['0', _TrackerMain_SMSFormat1],
            ['1', _TrackerMain_SMSFOrmat2]
        ]));
            cmbparams3 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_AutoShut, 0, "", createSimpleStore('valueid', 'val', Ext.ms02data.offonvalue));
            cmbparams4 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _AlarmResource_DeviceReboot, 0, "", createSimpleStore('valueid', 'val', Ext.ms02data.offonvalue));
            cmbparams5 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_GPSBlind, 0, "", createSimpleStore('valueid', 'val', Ext.ms02data.offonvalue));
            cmbparams6 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_LED, 0, "", createSimpleStore('valueid', 'val', [
            ['0', _TrackerMain_LEDNormal],
            ['1', _TrackerMain_LEDAutoShut]
        ]));
            cmbparams7 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_PowerOff, 0, "", createSimpleStore('valueid', 'val', Ext.ms02data.offonvalue));
            cmbparams8 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_IncomingRing, 0, "", createSimpleStore('valueid', 'val', Ext.ms02data.offonvalue));
        }
        else if (commandmodel == 1) {
            cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_LED, 0, "", createSimpleStore('valueid', 'val', [
                ['0', _TrackerMain_LEDNormal],
                ['1', _TrackerMain_LEDAutoShut]
            ]));
        }
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_Enginelimited) {
        reshowparams();

        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Condition, 0, "", belowstore);
        showOutputControl();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_EngineUnlimited) {
        reshowparams();
        if (showSMS) {
            if (gprsorsmsgroup.getValue().inputValue == 0)
                showOutputControl();
            else {
                cmbparams2 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Output, 255, '', getIndexStore(1, 5));
                cmbparams2.setValue('1');
                cmbparams3 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "", 255, '', outputstore);
                cmbparams3.setValue('1');
            }
        }
        else {
            showOutputControl();
        }
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_TriggeredAlarms) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Button + ' 1', 0, "", buttonpressreleasestore);
        cmbparams2 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Button + ' 2', 0, "", buttonpressreleasestore);
        cmbparams3 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Button + ' 3', 0, "", buttonpressreleasestore);
        cmbparams4 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Button + ' 4', 0, "", buttonpressreleasestore);
        cmbparams5 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Button + ' 5', 0, "", buttonpressreleasestore);
        cmbparams1.setWidth(200);
        cmbparams1.setValue('1');
        cmbparams2.setWidth(200);
        cmbparams2.setValue('1');
        cmbparams3.setWidth(200);
        cmbparams3.setValue('1');
        cmbparams4.setWidth(200);
        cmbparams4.setValue('1');
        cmbparams5.setWidth(200);
        cmbparams5.setValue('1');
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetSleepMode) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Level, 0, "", sleepstore);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetPowerDown) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Minutes + "(0-99)", 2, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetWiretapping) {
        if (commandmodel == 0) {
            reshowparams();
            txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_Number, 16, "", null);
            redolayoutparams();
        }
        else if (commandmodel == 1) {
            reshowparams();
            txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_ListeningNumber + "1", 16, "", null);
            txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_ListeningNumber + "2", 16, "", null);
            redolayoutparams();
        }
    }
    else if (cmdtext == _CommandExpression_SetTimeZone) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_TimeZone, 5, _TrackerMain_Minute, null);
        txtparams1.setMaxValue(65535);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GPRS_SetVeerReport) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Degree, 3, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_RebootGPS) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_SetGPSAntennaAlarm) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, '', 0, "", offonstore);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GPRS_SetHeartBeat) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Interval, 5, _TrackerMain_Minute, null);
        txtparams1.setMaxValue(65535);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GPRS_SetLogInterval) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Interval, 5, _TrackerMain_Second, null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GPRS_FormatLoggedData) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_GPRS_ReadLoggedData) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_GPRS_ReadInterval) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_ReadAuthorization) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Button, 0, "", butstore);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_ClearKilometers) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_ReasSNIMEIFirmware) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_Initialization) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_SetSMSCommnadHeader) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_EventID, 0, "", createEventCodeStore(EnumAuthType.SMS, true));
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_SMSHeader, 16, "", null);
        cmbparams1.setWidth(200);
        cmbparams1.setValue('1');
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetIntervalCounter) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Interval, 4, "10 * " + _TrackerMain_Second, null);
        //txtparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Counter, 5, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetDistanceInverval) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Distance, 9, _TrackerMain_Meter, null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetGPRS) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Status, 0, "", gprsstore);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_IP, 32, "", null);
        txtparams3 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Port, 5, "", null);
        txtparams4 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_APN, 32, "", null);
        txtparams5 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_GPRSUserName, 32, "", null);
        txtparams6 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_GPRSPassword, 32, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetSecondGPRS) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_IP, 32, "", null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Port, 5, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GetDetailLocation) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_DeleteEventGetNewEvent) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_EventID, 2, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GetAuthorizePhoneAndFlag) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Index, 0, "", getIndexStore(1, 3));
        cmbparams1.setValue(1);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetAuthorizePhoneAndFlag) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Index, 0, "", getIndexStore(1, 3));
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_SIMNumber, 16, "", null);
        cmbparams3 = createNewParamAndShow(EnumParamFieldType.MultiComboBoxField, _TrackerMain_EventID, 0, "", createEventCodeStore(EnumAuthType.SMS, false));
        cmbparams3.setWidth(200);
        cmbparams3.setValue('1');
        cmbparams1.setValue(1);
        redolayoutparams();

    }
    else if (cmdtext == _CommandExpression_SetSMSEventFlag || cmdtext == _CommandExpression_DeleteSMSEventFlag) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Index, 0, "", getIndexStore(1, 3));
        cmbparams2 = createNewParamAndShow(EnumParamFieldType.MultiComboBoxField, _TrackerMain_EventID, 0, "", createEventCodeStore(EnumAuthType.SMS, false));
        cmbparams2.setWidth(200);
        cmbparams2.setValue('1');
        cmbparams1.setValue(1);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_DeleteGeoFence) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Index, 0, "", getIndexStore(1, 8));
        cmbparams1.setValue(1);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetGPSSleepMode) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Level, 0, "", sleepstore);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetSleepTime) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Interval, 3, _TrackerMain_Minute, null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetSMSTimeZone) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_TimeZone, 5, _TrackerMain_Minute, null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetGPRSTimeZone) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_TimeZone, 5, _TrackerMain_Minute, null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetEventFlagforGPRS) {
        disableAllParamPanel();
        showGPRSAuthWindow();
    }
    else if (cmdtext == _CommandExpression_GetEventFlagforGPRS) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_Outputcontrol) {
        reshowparams();
        if (showmiles) {
            txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Speed, 3, _TrackerMain_MPH, null);
            txtparams1.maxValue = 155;
            txtparams1.minValue = 0;
            txtparams1.minText = _Message_MinText + ' 0';
            txtparams1.maxText = _Message_MaxText + ' 155';
        }
        else {
            txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Speed, 3, _TrackerMain_KMH, null);
            txtparams1.maxValue = 255;
            txtparams1.minValue = 0;
            txtparams1.minText = _Message_MinText + ' 0';
            txtparams1.maxText = _Message_MaxText + ' 255';
        }
        showOutputControl();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SendSMSFromGPRS) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_SIMNumber, 16, '', null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextArea, _TrackerMain_SMSBody, 140, '', null);
        txtparams2.setWidth(200);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_ProtocolControl) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Protocol, 0, "", eventtypestore);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_ReadEEPData) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_Offset, 4, '', null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_Length, 4, '', null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_ReadFirmwareandSN) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_RebootGSM) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_SetTowAlert) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Period, 3, _TrackerMain_Second, null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GetLastPicture) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_SetDNSServerIP) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_IP, 32, '', null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_ChangePassword) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Password, 6, '', null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_RetypePassword, 6, '', null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GetAllPictureName) {
        reshowparams();
        redolayoutparams();
        var count = devicestore.getCount();
        var i;
        var nochoose = true;
        for (i = 0; i < count; i++) {
            var record = devicestore.getAt(i);
            var choosed = record.get("choosed");
            var sssid = record.get("sssid");
            var trackername = record.get("trackername");
            if (choosed) {
                Ext.Ajax.request({
                    url: 'HandlerGetImageNameList',
                    method: 'post',
                    params: {
                        sssid: sssid,
                        trackername: trackername
                    },
                    success: function(r) {
                        var responsetext = r.responseText;
                        var p = responsetext.split(':');
                        if (p.length == 3) {

                            if (g_PhotoWindowDictionary.ContainsKey(p[0])) {
                                var tmpwin = g_PhotoWindowDictionary.Item(p[0]);
                                tmpwin.close();
                            }
                            var photolist = new PhotoListWindow(p[0], p[1], p[2]);
                            g_PhotoWindowDictionary.Add(p[0], photolist);
                        }
                    }
                });
            }
        }
    }
    else if (cmdtext == _CommandExpression_DelAllPicture) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_GetPhotoEventFlag) {
        disableAllParamPanel();
    }
    else if (cmdtext == _CommandExpression_SetPhotoEventFlag) {
        disableAllParamPanel();
        showPhotoAuthWindow();
    }
    else if (cmdtext == _CommandExpression_TakePhoto) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Index, 0, "", getIndexStore(1, 3));
        cmbparams1.setValue(1);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_RemoveBuffer) {
        reshowparams();
        //txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, '', 4, '', null);
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "", 0, "", delbufstore);
        cmbparams1.setValue(1);
        redolayoutparams();
    }
    //    else if (cmdtext == _CommandExpression_GPRS_Message) {
    //        reshowparams();
    //        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_Sender, 32, '', null);
    //        cmbparams2 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Index, 0, "", gprsmessagestore);
    //        txtparams3 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_Text, 150, '', null);
    //        redolayoutparams();
    //    }
    else if (cmdtext == _CommandExpression_GPRS_Control_Message) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_Text, 150, '', null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GPRS_Message) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Index, 0, "", gprsmessagestore);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextArea, _TrackerMain_Text, 150, '', null);
        txtparams2.addListener('change', function(obj, newValue, oldValue) {
            if (isUnicode(newValue))
                txtparams2.maxLength = 70;
            else
                txtparams2.maxLength = 150;
        });
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_ReadAuthNO) {
        reshowparams();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetGroupFunctionNO) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_FunctionsNumber + '1', 16, '', null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_FunctionsNumber + '2', 16, '', null);
        txtparams3 = createNewParamAndShow(EnumParamFieldType.TextField, _TrackerMain_FunctionsNumber + '3', 16, '', null);
        redolayoutparams();
    }

    else if (cmdtext == _CommandExpression_SetSmartSleepMode) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_SmartSleepMode, 0, "", smartsleepmodestore);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_AuthRFID) {
        reshowparams();
        redolayoutparams();
        //butsendcommand.disable();
        Ext.Ajax.request({
            url: 'HandlerGetAllRFID',
            method: 'post',
            success: function(r) {
                var responsetext = r.responseText;
                var p = responsetext.split(':');
                if (p.length == 3) {
                    var rfidauthwin = new RFIDAuthWindow(p[0], p[1], p[2], false);

                }
            }
        });
    }
    else if (cmdtext == _CommandExpression_BatchAuthRFID) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_FromRFID, 10, '', null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_RFIDCount, 3, '', null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_BatchDelRFID) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_FromRFID, 10, '', null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_RFIDCount, 3, '', null);

        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_CheckRFIDAuth) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, "RFID", 10, '', null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_CheckRFIDDBSync) {
        reshowparams();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_DelAuthedRFID) {
        reshowparams();
        redolayoutparams();
        //txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, "RFID", 255, '', null);

        var count = devicestore.getCount();
        var i;
        var nochoose = true;
        for (i = 0; i < count; i++) {
            var record = devicestore.getAt(i);
            var choosed = record.get("choosed");
            var sssid = record.get("sssid");
            var trackername = record.get("trackername");
            if (choosed) {
                Ext.Ajax.request({
                    url: 'HandlerGetAuthedRFIDList',
                    method: 'post',
                    params: {
                        sssid: sssid,
                        trackername: trackername
                    },
                    success: function(r) {
                        var responsetext = r.responseText;
                        var p = responsetext.split(':');
                        if (p.length == 3) {

                            if (g_RFIDWindowDictionary.ContainsKey(p[0])) {
                                var tmpwin = g_RFIDWindowDictionary.Item(p[0]);
                                tmpwin.close();
                            }
                            var rfidauthwin = new RFIDAuthWindow(p[0], p[1], p[2], true, null);
                            g_RFIDWindowDictionary.Add(p[0], rfidauthwin);
                        }
                    }
                });
            }
        }
    }
    else if (cmdtext == _CommandExpression_ReadAuthedRFID) {
        reshowparams();
        redolayoutparams();

    }
    else if (cmdtext == _CommandExpression_Set_BaseMileage) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_BaseMileage + "(Km)", 8, '', null);
        redolayoutparams();
    }

    else if (cmdtext == _CommandExpression_SetSMSIntervalCounter) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Interval, 4, _TrackerMain_Minute, null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Counter, 5, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_OTAUpgrade || cmdtext == _CommandExpression_CancelOTA) {
        reshowparams();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GPSOpenClose) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "GPS", 0, "", offonstore);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_ClearKilometersRuntime) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Clear, 0, "", clearrecordstore);
        cmbparams1.setValue(1);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetKilometersRuntime) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_RunTime, 10, _TrackerMain_Seconds, null);
        txtparams1.allowBlank = true;
        txtparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Odometer, 10, _TrackerMain_Meter, null);
        txtparams2.allowBlank = true;
        redolayoutparams()
    }
    else if (cmdtext == _CommandExpression_ReadGeoFence) {
        reshowparams();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_ReadIPPort) {
        reshowparams();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_ReadAPN) {
        reshowparams();
        redolayoutparams();
    }
    else if (cmdtext == _SettingTool_ReadAllParams) {
        reshowparams();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_EngineCheck) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Clear, 0, "", createSimpleStore('valueid', 'val', [
            ['0', _TrackerMain_CancelEngineCheck],
            ['1', _TrackerMain_SetEngineCheck]
        ]));
        cmbparams1.setValue('0');
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_3DWakeUpSet) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_Clear, 0, "", createSimpleStore('valueid', 'val', [
                ['0', _TrackerMain_3DNoWakeUp],
                ['1', _TrackerMain_3DWakeUp]
            ]));

        cmbparams1.setValue('0');
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_FuelAlarmSettings) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_HighFuelPercent, 2, "%", null);

        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetFuelDown) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_FuelDownInterval, 3, _TrackerMain_Minutes, null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_FuelDownPercent, 2, "%", null);
        txtparams2.setMaxValue(100);
        txtparams2.setMinValue(0);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_UserDefinedCommand) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, "", 255, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_AsyncExtendSensor) {
        reshowparams();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetFuelSensorType) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "", 0, "", new Ext.data.ArrayStore({
            field: ['valueid', 'val'],
            data: [[0, _TrackerMain_Null], [1, _TrackerMain_FuelC], [2, _TrackerMain_FuelR], [3, _TrackerMain_FuelSensorV1]]
        }));
        redolayoutparams();
    }
    /*********************越南定制项目***************/
    else if (cmdtext == _CommandExpression_PulseCalibration) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _Ext_CancelCalibration, 255, "", noyesstore);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_InformationCharacter) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _Ext_SetParam, 255, "", extprintinfostore);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextArea, _Ext_PrintInfoHeader, 32, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetPrintPeriod) {
        reshowparams();
        //panelparamscolumn1.add(createNewParamDateTimeField());
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _TrackerMain_D, 0, "", getIndexStore(0, 31));
        cmbparams1.setValue(0);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_CheckIgnition) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "", 255, "", offonstore);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GPRSIntervalWhenIgnitionOff) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Interval, 4, "10 * " + _TrackerMain_Second, null);
        //txtparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_Counter, 5, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_SetFuelAlarm) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _TrackerMain_FuelPercent, 2, "%", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_RFIDOut1) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "", 255, "", offonstore);
        redolayoutparams();
    }
    /*********************国标系列命令***********************/
    else if (cmdtext == _CommandExpression_GBManulaParams) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, "命令ID", 255, "", null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextArea, "命令参数", 9999, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBSetGeoFence) {

        disableAllParamPanel();
        panelgbareaparams.show();
        var maxSpeed = null;
        var duration = null;
        var areatype = null, areacontrol = null;
        var datetimePanel = null;

        function showSpeedLimitAndStartEndDateTimeParams() {
            var value = cbAreaProperty.getValue();
            var valArray = value.split(',');
            var isOpenSpeedLimit = false;
            var isOpenStartAndEndDateTime = false;
            for (var i = 0; i < valArray.length; i++) {
                if (valArray[i] != "") {
                    if (valArray[i] == 1) {
                        isOpenSpeedLimit = true;
                    }
                    else if (valArray[i] == 0) {
                        isOpenStartAndEndDateTime = true;
                    }
                }
            }
            if (maxSpeed != null) {
                panelgbareaotherparams.remove(maxSpeed, true);
                Ext.destroy(maxSpeed);
            }
            if (duration != null) {
                panelgbareaotherparams.remove(duration, true);
                Ext.destroy(duration);
            }
            if (datetimePanel != null) {
                panelgbareaotherparams.remove(datetimePanel, true);
                Ext.destroy(datetimePanel);
            }
            if (isOpenStartAndEndDateTime) {
                datetimePanel = createNewParamDateTimeField();
                panelgbareaotherparams.add(datetimePanel);
            }
            if (isOpenSpeedLimit) {
                maxSpeed = createNewParamNumberField("最高速度(km/h)", 10, false, 'txt_max_speed');
                duration = createNewParamNumberField("持续时间(s)", 10, false, 'txt_duration');
                panelgbareaotherparams.add(maxSpeed);
                panelgbareaotherparams.add(duration);
            }
            panelgbareaotherparams.doLayout();
        }

        function showSetRouteAreaParams() {
            var butdrawcgeofence = new Ext.Button({
                text: '绘制路线',
                style: 'margin-left:110px',
                handler: function() {
                    if (imap != null) {
                        imap.drawRouteLine(function(points) {
                            paramsArray.clear();
                            if (points) {
                                var count = points.length;
                                txtVertexCount.setValue(count);
                                paramsArray.push(UInt16ToWORDString(count));
                                for (var i = 0; i < count; i++) {
                                    var point = points[i].point;
                                    paramsArray.push(UInt32ToDWORDString(i)); //拐点ID
                                    paramsArray.push(UInt32ToDWORDString(i)); //路段ID
                                    paramsArray.push(UInt32ToDWORDString(point.lat().toFixed(6) * 1000000));
                                    paramsArray.push(UInt32ToDWORDString(point.lng().toFixed(6) * 1000000));
                                    paramsArray.push(50); //路段宽度
                                    var routeSectionBit = padLeft('', '0', 8);
                                    if (panelgbareadefaultparams.items.items[5].getValue() == 1) {
                                        routeSectionBit = bitSetbitSet(routeSectionBit, 2, 1);
                                    }
                                    if (panelgbareadefaultparams.items.items[6].getValue() == 1) {
                                        routeSectionBit = bitSetbitSet(routeSectionBit, 3, 1);
                                    }
                                    paramsArray.push(intStringToHexString(routeSectionBit)); //路段属性
                                }
                            }
                        });
                    }
                }
            });
            var txtVertexCount = createNewParamNumberField('拐点总数', 11, true, 'txt_veer_point_count');
            panelgbareaotherparams.add(txtVertexCount);
            panelgbareaotherparams.add(butdrawcgeofence);
            panelgbareaotherparams.doLayout();
        }

        function showSetCircleAreaParams() {
            var txtLatitude = createNewParamNumberField('中心点纬度', 10, true, 'txt_circle_latitude');
            var txtLongitude = createNewParamNumberField('中心点经度', 10, true, 'txt_circle_longitude');
            var txtRadius = createNewParamNumberField('半径', 10, true, 'txt_circle_radius');
            var butdrawcgeofence = new Ext.Button({
                text: _TrackerMain_DrawGeo,
                style: 'margin-left:110px',
                handler: function() {
                    imap.beginDrawCircleGeoFence(0);
                    imap.FnCircleGeoFenceCallBack = function(lat, lng, radius) {
                        txtLatitude.setValue(lat.toFixed(6));
                        txtLongitude.setValue(lng.toFixed(6));
                        txtRadius.setValue(radius.toFixed(0));
                    };
                }
            });
            panelgbareaotherparams.add(txtLatitude);
            panelgbareaotherparams.add(txtLongitude);
            panelgbareaotherparams.add(txtRadius);
            panelgbareaotherparams.add(butdrawcgeofence);
            panelgbareaotherparams.doLayout();
        }
        function showSetRectangleAreaParams() {
            var butdrawcgeofence = new Ext.Button({
                text: _TrackerMain_DrawGeo,
                style: 'margin-left:110px',
                handler: function() {
                    if (imap != null) {
                        imap.beginDrawGeoFence(0);
                        imap.FnGeoFenceCallBack = function(y1, x1, y2, x2) {
                            var xmin = x1 < x2 ? x1 : x2;
                            var xmax = x1 > x2 ? x1 : x2;
                            var ymin = y1 < y2 ? y1 : y2;
                            var ymax = y1 > y2 ? y1 : y2;
                            txtUperLeftX.setValue(ymin.toFixed(6));
                            txtUperLeftY.setValue(xmin.toFixed(6));
                            txtLowerRightX.setValue(ymax.toFixed(6));
                            txtLowerRightY.setValue(xmax.toFixed(6));
                        };
                    }
                }
            });
            var txtUperLeftX = createNewParamNumberField('左上纬度', 11, true, 'txt_upper_left_latitude');
            var txtUperLeftY = createNewParamNumberField('左上经度', 11, true, 'txt_upper_left_longitude');
            var txtLowerRightX = createNewParamNumberField('右下纬度', 11, true, 'txt_lower_right_latitude');
            var txtLowerRightY = createNewParamNumberField('右下经度', 11, true, 'txt_lower_right_longitude');
            panelgbareaotherparams.add(txtUperLeftX);
            panelgbareaotherparams.add(txtUperLeftY);
            panelgbareaotherparams.add(txtLowerRightX);
            panelgbareaotherparams.add(txtLowerRightY);
            panelgbareaotherparams.add(butdrawcgeofence);
            panelgbareaotherparams.doLayout();
        }

        function showSetPolygonAreaParams() {
            var butdrawcgeofence = new Ext.Button({
                text: _TrackerMain_DrawGeo,
                style: 'margin-left:110px',
                handler: function() {
                    if (imap != null) {
                        imap.startDrawPolygonGeofence(0, null, function(ptsString, count) {
                            txtVertexCount.setValue(count);
                            paramsArray.clear();
                            paramsArray.push(UInt16ToWORDString(count));
                            var points = ptsString.split("|");
                            for (var i = 0; i < points.length; i++) {
                                var latitude = parseFloat(parseFloat(points[i].split(',')[0]).toFixed(6)) * 1000000;
                                var longitude = parseFloat(parseFloat(points[i].split(',')[1]).toFixed(6)) * 1000000;
                                paramsArray.push(UInt32ToDWORDString(latitude));
                                paramsArray.push(UInt32ToDWORDString(longitude));
                            }
                        });
                    }
                }
            });

            var txtVertexCount = createNewParamNumberField('顶点总数', 11, true, 'txt_vertex_count');
            panelgbareaotherparams.add(txtVertexCount);
            panelgbareaotherparams.add(butdrawcgeofence);
            panelgbareaotherparams.doLayout();
        }
        var comboAreaType = createComboBoxForCommand(false, "区域类型", Ext.ms02data.areatype, 'valueid', 'val', false, true, true, 150, null, function(a, b, value) {
            areatype = value;
            panelgbareaotherparams.removeAll(true);
            if (areacontrol == null)
                return;
            if (areacontrol != 3) {
                if (areatype == 0) {
                    showSetCircleAreaParams();
                }
                else if (areatype == 1) {
                    showSetRectangleAreaParams();
                }
                else if (areatype == 2) {
                    showSetPolygonAreaParams();
                }
                else if (areatype == 3) {
                    //显示路径区域参数
                    showSetRouteAreaParams();
                }
                showOrHideGbDefaultParams(true);
            }
            else {
                //删除电子区域
                showOrHideGbDefaultParams(false);

            }
            panelgbareaotherparams.doLayout();
        });
        panelgbareadefaultparams.add(comboAreaType);

        var comboSettingProperty = createComboBoxForCommand(false, "设置属性", Ext.ms02data.areacontrol, 'valueid', 'val', false, true, true, 150, null, function(a, b, value) {
            areacontrol = value;
            panelgbareaotherparams.removeAll(true);
            if (areatype == null)
                return;
            if (areacontrol != 3) {
                if (areatype == 0) {
                    showSetCircleAreaParams();
                }
                else if (areatype == 1) {
                    showSetRectangleAreaParams();
                }
                else if (areatype == 2) {
                    showSetPolygonAreaParams();
                }
                else if (areatype == 3) {
                    showSetRouteAreaParams();
                }
                showOrHideGbDefaultParams(true);
            }
            else {
                //删除电子区域
                showOrHideGbDefaultParams(false);
                panelgbareaotherparams.removeAll(true);
                var tmptxt = createNewParamTextArea("区域ID", 1024, false, 't_delid', 't_delid');

                panelgbareaotherparams.add(tmptxt);
                panelgbareaotherparams.show();
                //showOrHideGbDefaultParams(true);

            }
            panelgbareaotherparams.doLayout();
        });
        panelgbareadefaultparams.add(comboSettingProperty);
        var txtAreaCount = createNewParamNumberField("区域总数", 10, true);
        txtAreaCount.setValue(1);
        panelgbareadefaultparams.add(txtAreaCount);
        panelgbareadefaultparams.add(createNewParamNumberField("区域ID", 10));
        var cbAreaProperty = createNewMultiParamCmbField(Ext.ms02data.areaproperty, "区域属性", "");
        cbAreaProperty.addListener('collapse', showSpeedLimitAndStartEndDateTimeParams);
        panelgbareadefaultparams.add(cbAreaProperty);
        panelgbareadefaultparams.add(createNewParamRadioGroup('', ['北纬', '南纬'], 120, 'cb_latitude'));
        panelgbareadefaultparams.add(createNewParamRadioGroup('', ['东经', '西经'], 120, 'cb_longitude'));
        panelgbareadefaultparams.doLayout();
        showOrHideGbDefaultParams(false);
    }
    else if (cmdtext == _CommandExpression_GBSetParams) {
        reshowparams();
        redolayoutparams();

        GBTrackerSettingsWindow();
    }
    else if (cmdtext == _CommandExpression_GBCheckParams) {
        reshowparams();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBControlTracker) {
        //终端控制
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "命令", 0, "", gbcontroltrackercmdstore);
        cmbparams1.addListener('select', function(cmb, record, index) {
            if (index == 0 || index == 1)
                txtparams2.enable();
            else
                txtparams2.disable();
        });
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextArea, "文本信息", 1024, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBCheckLocation) {
        reshowparams();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBTempLocationTrack) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, "时间间隔", 255, "秒(s)", null);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, "位置跟踪有效期", 255, "秒(s)", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBSendText) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.MultiComboBoxField, "类型", 0, "", gbtextsignstore);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextArea, "文本信息", 1024, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBSetEvent) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "设置类型", 0, "", gbeventsettypestore);
        cmbparams1.setWidth(200);
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, "设置总数", 255, "", null);
        txtparams1.setValue(1);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, "事件ID", 255, "", null);
        txtparams3 = createNewParamAndShow(EnumParamFieldType.TextArea, "事件内容", 1024, "", null);
        txtparams3.allowBlank = true;
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBQuestion) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.MultiComboBoxField, "标志", 0, "", gbquestionsignstore);
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextArea, "问题", 1024, "", null);
        txtparams1.setHeight(40); txtparams1.setWidth(180);
        createNewParamAndShow(EnumParamFieldType.TextField, "答案内容", 1024, "", null, "txt_question_for_answer");
        btnAddNewAnswer.show();
        btnRemoveAnswer.show();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBSetMenu) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "设置类型", 0, "", gbmenusettypestore);
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, "信息项总数", 255, "", null);
        cmbparams2 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "信息类型", 0, "", gbmessagetypestore);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, "信息名称", 255, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBInfoService) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "信息类型", 0, "", gbmessagetypestore);
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextArea, "信息内容", 255, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBPhoneTo) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "标志", 0, "", gbphonecallsignstore);
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextArea, "电话号码", 20, "", null);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBSetPhoneBook) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "设置类型", 0, "", gbphonebooksettypestore);
        cmbparams1.setWidth(200);
        cmbparams1.addListener('select', function(obj, record, index) {
            if (index == 0) {
                var myflags = panelparamscolumn1.find('name', "cmb_contact_flag");
                var mynumbers = panelparamscolumn1.find('name', "txt_contact_phonenumber");
                var mynames = panelparamscolumn1.find('name', "txt_contact_username");
                var mm = 0;
                panelparamscolumn1.remove("cmb_contact_flag");
                panelparamscolumn1.remove("txt_contact_phonenumber");
                panelparamscolumn1.remove("txt_contact_username");
            }
        });
        btnAddNewContact.show();
        btnRemoveContact.show();
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBControlVehicle) {
        reshowparams();
        radiogroupparam1 = createNewParamRadioGroup("车门控制", ["车门解锁", "车门加锁"], 150, "car_door")
        panelparamscolumn1.add(radiogroupparam1);
        redolayoutparams();
    }

    else if (cmdtext == _CommandExpression_GBSetLog) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "命令字", 0, "", gbcollectcommandstore);
        cmbparams1.setWidth(200);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBLogParamSet) {
        reshowparams();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "命令字", 0, "", gbsendlogstore);
        cmbparams1.setWidth(200);
        cmbparams1.addListener("select", function(combo) {
            var value = combo.getValue();
            var allDataAreaArray = panelparamscolumn1.find('name', 'txt_data_area');
            Ext.each(allDataAreaArray, function(item, index) {
                panelparamscolumn1.remove(item, true);
                Ext.destroy(item);
            });
            if (value == "81") {
                txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, "驾驶员代码", 255, "", null, 'txt_data_area');
                txtparams1.setValue("000");
                txtparams1.setDisabled(true);
                txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, "驾驶证号码", 255, "", null, 'txt_data_area');
            }
            else if (value == "82") {
                txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, "车辆VIN号码", 255, "", null, 'txt_data_area');
                txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, "车牌号码", 255, "", null, 'txt_data_area');
                txtparams3 = createNewParamAndShow(EnumParamFieldType.TextField, "分类", 255, "", null, 'txt_data_area');
            }
            else if (value == "C2") {
                txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, "时钟", 17, "", null, 'txt_hex_data');
            }
            else if (value == "C3") {
                txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, "车辆特征系数", 3, "", null, 'txt_data_area');
            }
            panelparamscolumn1.doLayout();
        });
        panelparamscolumn1.doLayout();
    }
    else if (cmdtext == _CommandExpression_GBTakePhoto) {
        reshowparams();
        createNewParamAndShow(EnumParamFieldType.TextField, "通道ID", 255, "", null, "param_gb_shoot");
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "拍摄命令", 0, "", gbshootcommandstore, "param_gb_shoot").addListener('select', function(cmbbox, record, index) {
            if (index == 0 || index == 1) {
                cmbbox.setEditable(false);
            }
            else {
                cmbbox.emptyText = "请输入照片数";
                cmbbox.clearValue();
                cmbbox.forceSelection = false;
                cmbbox.maxLengthText = 4;
                cmbbox.setEditable(true);
            }
        });
        createNewParamAndShow(EnumParamFieldType.NumberField, "拍照间隔/录像时间", 255, "", null, "param_gb_shoot");
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "保存标志", 0, "", gbshootsavesignstore, "param_gb_shoot");
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "分辨率", 0, "", gbshootresolutionstore, "param_gb_shoot");
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "图像/视频质量", 0, "", getIndexStore(1, 10), "param_gb_shoot");
        createNewParamAndShow(EnumParamFieldType.NumberField, "亮度", 255, "", null, "param_gb_shoot").setMaxValue(255);
        createNewParamAndShow(EnumParamFieldType.NumberField, "对比度", 255, "", null, "param_gb_shoot").setMaxValue(127);
        createNewParamAndShow(EnumParamFieldType.NumberField, "饱和度", 255, "", null, "param_gb_shoot").setMaxValue(127);
        createNewParamAndShow(EnumParamFieldType.NumberField, "色度", 255, "", null, "param_gb_shoot").setMaxValue(255);
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBMultimediaSearch) {
        reshowparams();
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "多媒体类型", 0, "", gbmediatypestore, "param_gb_media_search");
        createNewParamAndShow(EnumParamFieldType.NumberField, "通道ID", 255, "", null, "param_gb_media_search");
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "事件项编码", 255, "", gbmediaeventcodestore, "param_gb_media_search");
        panelparamscolumn1.add(createNewParamDateTimeField());
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBMultimediaUpload) {
        reshowparams();
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "多媒体类型", 0, "", gbmediatypestore, "param_gb_media_upload");
        createNewParamAndShow(EnumParamFieldType.NumberField, "通道ID", 255, "", null, "param_gb_media_upload");
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "事件项编码", 255, "", gbmediaeventcodestore, "param_gb_media_upload");
        panelparamscolumn1.add(createNewParamDateTimeField());
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "删除标志", 0, "", gbmediadeletesignstore, "param_gb_media_upload");
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBBeginRecordVoice) {
        reshowparams();
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "录音命令", 0, "", gbvoicerecordcommandstore, "param_gb_voice_record");
        createNewParamAndShow(EnumParamFieldType.NumberField, "录音时间", 255, "", null, "param_gb_voice_record");
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "保存标志", 255, "", gbvoicerecordsavesignstore, "param_gb_voice_record");
        createNewParamAndShow(EnumParamFieldType.ComboBoxField, "音频采样率", 255, "", gbvoicefrequencystore, "param_gb_voice_record");
        redolayoutparams();
    }
    else if (cmdtext == _CommandExpression_GBTransData) {
        reshowparams();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.TextField, "透传16进制数据", 1024, "", null, '');
        redolayoutparams();

    }
    /**********************************End GB Command***************************************/
    /**********************************Begin LED Command***************************************/
    else if (cmdtext == _CommandExpression_LED) {
        reshowparams();
        cmdledcommand.show();
        redolayoutparams();
    }
    /**********************************End LED Command***************************************/
}

function reshowledparam(){
    if (panelparamscolumn1 != null)
        panelparamscolumn1.removeAll();
    if (panelparamscolumn2 != null)
        panelparamscolumn2.removeAll();
    if (panelparams != null)
        panelparams.hide();
    txtparams1 = null;
    txtparams2 = null;
    txtparams3 = null;
    txtparams4 = null;
    txtparams5 = null;
    txtparams6 = null;
    panelparams.show();
}
    
function  chooseledcommandandshowparams(cmdtext){
    if (cmdtext == _CommandExpression_LED_AddAdvertisement) {
        reshowledparam();
         var stofont = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_Font_Sim],[1,_LED_Font_Blod],[2,_LED_Font_Song],[3,_LED_Font_Hei],[4,_LED_Font_Kai],[5,_LED_Font_XinSong]]
        });
        
var stocolor = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[1,_Color_Red],[2,_Color_Yellow],[3,_Color_Green],[4,_Color_AntiRed],[5,_Color_AntiYellow]]
        });
var stomove = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[1,_LED_MoveLeft],[2,_LED_MoveRight],[3,_LED_MoveUp],[4,_LED_MoveDown],[5,_LED_Keep]]
        });
 var stospeed = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_Speed0],[1,_LED_Speed1],[2,_LED_Speed2],[3,_LED_Speed3],[4,_LED_Speed4]]
        });       
 var stostoptype= new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_StopModel1],[1,_LED_StopModel2]]
        });    
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_Font, 0, "", stofont);
        cmbparams2 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _Color, 0, "", stocolor);
        cmbparams3 = createNewParamAndShow(EnumParamFieldType.ComboBoxField,_LED_MoveDirection, 0, "", stomove);
        cmbparams4 = createNewParamAndShow(EnumParamFieldType.ComboBoxField,_LED_Speed, 0, "", getIndexStore(0,15));
        txtparams4 = createNewParamAndShow(EnumParamFieldType.NumberField, _LED_KeepTime, 3,_TrackerMain_Second,null);
        cmbparams5 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_StopModel, 0, "", stostoptype);
        
        createNewParamAndShow(EnumParamFieldType.Date,_LED_StartDate,0,"",null,'advstartdate');
        createNewParamAndShow(EnumParamFieldType.Date,_LED_StopDate,0,"",null,'advstopdate');
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _LED_MessageShowTime, 255, _TrackerMain_Second,null);
        
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_DelAdvertisement){
        
    }
    else if(cmdtext == _CommandExpression_LED_DelAllAdvertisement){
        reshowledparam();
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_GetAdvertisementCount){
        reshowledparam();
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_GetAdvertisement){
        reshowledparam();
        //cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_MailboxNumber, 0, getIndexStore(0,255));
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _LED_MailboxNumber, 3,"",null);
        txtparams1.setMaxValue(255);
        txtparams1.setMinValue(0);
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_SendMessage){
        reshowledparam();
         var stofont = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_Font_Sim],[1,_LED_Font_Blod],[2,_LED_Font_Song],[3,_LED_Font_Hei],[4,_LED_Font_Kai],[5,_LED_Font_XinSong]]
        });
        
        var stocolor = new Ext.data.ArrayStore({
                    fields: [{name:'valueid',type:'integer'}, 'val'],
                    data: [[1,_Color_Red],[2,_Color_Yellow],[3,_Color_Green],[4,_Color_AntiRed],[5,_Color_AntiYellow]]
                });
        var stomove = new Ext.data.ArrayStore({
                    fields: [{name:'valueid',type:'integer'}, 'val'],
                    data: [[1,_LED_MoveLeft],[2,_LED_MoveRight],[3,_LED_MoveUp],[4,_LED_MoveDown],[5,_LED_Keep]]
                });
         var stospeed = new Ext.data.ArrayStore({
                    fields: [{name:'valueid',type:'integer'}, 'val'],
                    data: [[0,_LED_Speed0],[1,_LED_Speed1],[2,_LED_Speed2],[3,_LED_Speed3],[4,_LED_Speed4]]
                });       
         var stostoptype= new Ext.data.ArrayStore({
                    fields: [{name:'valueid',type:'integer'}, 'val'],
                    data: [[0,_LED_StopModel1],[1,_LED_StopModel2]]
                });    
       var stoalarmtype = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_Normal],[1,_LED_Urgent]]
        });
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_ShowLevel, 0, "",stoalarmtype);
        
        var stoexittype = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_ExitType1],[1,_LED_ExitType2],[2,_LED_ExitType3],[3,_LED_ExitType4]] //,[4,_LED_ExitType5]]
        });
        cmbparams2 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_ExitModel, 0,"", stoexittype);
        var b1=createNewParamAndShow(EnumParamFieldType.Time,_LED_LifeTime,0,"",null,'sendmessagedate','sendmessagedate');
        b1.setValue("00:00");
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _LED_ImmiShowTime, 65535, "",null);
        txtparams1.setValue(0);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.NumberField, _LED_ShowTimes, 255,"",null);
        txtparams2.setValue(0);
        
        cmbparams3 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_Font, 0, "", stofont);
        cmbparams4 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _Color, 0, "", stocolor);
        cmbparams5 = createNewParamAndShow(EnumParamFieldType.ComboBoxField,_LED_MoveDirection, 0, "", stomove);
        cmbparams6 = createNewParamAndShow(EnumParamFieldType.ComboBoxField,_LED_Speed, 0, "", stospeed);
        txtparams3 = createNewParamAndShow(EnumParamFieldType.NumberField, _LED_KeepTime, 3,"",null);
        txtparams4 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_StopModel, 0, "", stostoptype);
        txtparams5= createNewParamAndShow(EnumParamFieldType.TextArea, _LED_Body, 255, "", null);
        //txtparams3 = createNewParamAndShow(EnumParamFieldType.NumberField, "信息 ID号", 255, "s",null);
        
        b1.setVisible(false);
        txtparams1.setVisible(false);
        txtparams2.setVisible(false);
        cmbparams2.addListener('select',function(obj,record,index){
            if(index == 0){
                b1.setVisible(false);
                txtparams1.setVisible(false);
                txtparams2.setVisible(false);
            }
            else if(index ==1){
                b1.setVisible(true);
                txtparams1.setVisible(false);
                txtparams2.setVisible(false);
            }
            else if(index == 2){
                b1.setVisible(false);
                txtparams1.setVisible(true);
                txtparams2.setVisible(false);
            }
            else if(index == 3){
                b1.setVisible(false);
                txtparams1.setVisible(false);
                txtparams2.setVisible(true);
            }
            else if(index == 4){
                b1.setVisible(true);
                txtparams1.setVisible(false);
                txtparams2.setVisible(false);
            }
        });
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_BreakMessage){
        reshowledparam();
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_SetAlarm){
        reshowledparam();
        var stoalarmtype = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_AlarmType1],[1,_LED_AlarmType2]]
        });
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_RFlag, 0, "", stoalarmtype);
        txtparams2 = createNewParamAndShow(EnumParamFieldType.TextField, _LED_AlarmText, 8, "",null);
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_ShowAlarm){
        reshowledparam();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField, _LED_KeepAlarmTimeSpan, 65535, _TrackerMain_Second,null);
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_HideAlarm){
        reshowledparam();
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_SetDefaultMessage){
        reshowledparam();
        var stotype = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_ShowSysTime],[1,_LED_ShowDefaultText]]
        });
        cmbparams6 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_DefaultShow, 0, "",stotype);
        
        var stofont = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_Font_Sim],[1,_LED_Font_Blod],[2,_LED_Font_Song],[3,_LED_Font_Hei],[4,_LED_Font_Kai],[5,_LED_Font_XinSong]]
        });
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_Font, 0, "", stofont);
        var stocolor = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[1,_Color_Red],[2,_Color_Yellow],[3,_Color_Green],[4,_Color_AntiRed],[5,_Color_AntiYellow]]
        });
        cmbparams2 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _Color, 0, "", stocolor);
        var stomove = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[1,_LED_MoveLeft],[2,_LED_MoveRight],[3,_LED_MoveUp],[4,_LED_MoveDown]]
        });
        cmbparams3 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_MoveDirection, 0, "", stomove);
        var stospeed = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_Speed0],[1,_LED_Speed1],[2,_LED_Speed2],[3,_LED_Speed3],[4,_LED_Speed4]]
        });
        cmbparams4 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_Speed, 0, "", stospeed);
        txtparams4 = createNewParamAndShow(EnumParamFieldType.NumberField, _LED_KeepTime, 3, "", null);
        txtparams4.setValue(0);
        var stostoptype= new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_StopModel1],[1,_LED_StopModel2]]
        });
        cmbparams5 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_StopModel, 0, "", stostoptype);

        txtparams5 = createNewParamAndShow(EnumParamFieldType.TextArea, _NewForText_ValueText, 128, "", null);
        cmbparams1.setVisible(false);
        cmbparams2.setVisible(false);
        cmbparams3.setVisible(false);
        cmbparams4.setVisible(false);
        txtparams4.setVisible(false);
        cmbparams5.setVisible(false);
        txtparams5.setVisible(false);
        cmbparams6.addListener('select', function(obj, record, index) {
            if (index == 0) {
                cmbparams1.setVisible(false);
                cmbparams2.setVisible(false);
                cmbparams3.setVisible(false);
                cmbparams4.setVisible(false);
                txtparams4.setVisible(false);
                cmbparams5.setVisible(false);
                txtparams5.setVisible(false);
            }
            else {
                cmbparams1.setVisible(true);
                cmbparams2.setVisible(true);
                cmbparams3.setVisible(true);
                cmbparams4.setVisible(true);
                txtparams4.setVisible(true);
                cmbparams5.setVisible(true);
                txtparams5.setVisible(true);
            }
        });
        
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_SetTime){
        reshowledparam();
        var d= createNewParamAndShow(EnumParamFieldType.Date,_LED_SetDate,0,"",null,'','correctdate');
        d.format = "Y-m-d";
        var t= createNewParamAndShow(EnumParamFieldType.Time,_LED_SetTime,0,"",null,'','correcttime');
        t.format = "H:i:s";
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_GetTime){
        reshowledparam();
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_SetBrightness){
        reshowledparam();
        var stotype = new Ext.data.ArrayStore({
            fields: [{name:'valueid',type:'integer'}, 'val'],
            data: [[0,_LED_LightType1],[1,_LED_LightType2],[2,_LED_LightType3]]
        });
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_LightControlType, 0, "", stotype);
        cmbparams2 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_LightValue, 0, "", getIndexStore(0,15));
        
        cmbparams1.addListener('select',function(obj,record,index){
            if(index == 1){
                b1.setVisible(true);
                b2.setVisible(true);
                b3.setVisible(true);
                b4.setVisible(true);
                cmbparams3.setVisible(true);
                cmbparams4.setVisible(true);
                cmbparams5.setVisible(true);
                cmbparams6.setVisible(true);
            }
            else{
                b1.setVisible(false);
                b2.setVisible(false);
                b3.setVisible(false);
                b4.setVisible(false);
                cmbparams3.setVisible(false);
                cmbparams4.setVisible(false);
                cmbparams5.setVisible(false);
                cmbparams6.setVisible(false);
            }
        });
        var b1 = createNewParamAndShow(EnumParamFieldType.Time,_LED_LightControlTime+"1",0,"",null,'','btime1');
        b1.setValue("00:00");
        cmbparams3 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_LightValue+"1", 0, "", getIndexStore(0,15)); 
        var b2 =createNewParamAndShow(EnumParamFieldType.Time,_LED_LightControlTime+"2",0,"",null,'','btime2');
        b2.setValue("00:00");
        cmbparams4 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_LightValue+"2", 0, "", getIndexStore(0,15)); 
        var b3 =createNewParamAndShow(EnumParamFieldType.Time,_LED_LightControlTime+"3",0,"",null,'','btime3');
        b3.setValue("00:00");
        cmbparams5 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_LightValue+"3", 0, "", getIndexStore(0,15)); 
        var b4 =createNewParamAndShow(EnumParamFieldType.Time,_LED_LightControlTime+"4",0,"",null,'','btime4');
        b4.setValue("00:00");
        cmbparams6 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_LightValue+"4", 0, "", getIndexStore(0,15)); 
        
        b1.setVisible(false);
        b2.setVisible(false);
        b3.setVisible(false);
        b4.setVisible(false);
        cmbparams3.setVisible(false);
        cmbparams4.setVisible(false);
        cmbparams5.setVisible(false);
        cmbparams6.setVisible(false);
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_GetBrightness){
        reshowledparam();
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_SetPowerOnWaitingTime){
        reshowledparam();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField,_LED_Time,255,_TrackerMain_Seconds,null);
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_SearchWorkingStatus){
        reshowledparam();
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_TimerSwitch){
        reshowledparam();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_WorkModel, 0, "", new Ext.data.ArrayStore({
            fields:['valueid','val'],
            data:[['0',_LED_WorkAllDay],['1',_LED_WorkOnTime]]
        }));
        var b1 = createNewParamAndShow(EnumParamFieldType.Time, _LED_StartTimeSpan, 0, "", null, '', 'workbegintime');
        var b2 = createNewParamAndShow(EnumParamFieldType.Time, _LED_StopTimeSpan, 0, "", null, '', 'workendtime');
        b1.setValue("00:00");
        b2.setValue("23:59");
        b1.setVisible(false);
        b2.setVisible(false);
        cmbparams1.addListener('select', function(obj, record, index) {
            if (index == 0) {
                b1.setVisible(false);
                b2.setVisible(false);
            }
            else {
                b1.setVisible(true);
                b2.setVisible(true);
            }
        });
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_LEDSwitch){
        reshowledparam();
        panelparams.show();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, "", 0, "", new Ext.data.ArrayStore({
            fields: ['valueid', 'val'],
            data: [['0',_LED_Close],['1',_LED_Open],['2',_LED_Reset]]
        }));
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_LightTest){
        reshowledparam();
        txtparams1 = createNewParamAndShow(EnumParamFieldType.NumberField,_LED_Time,255,_TrackerMain_Seconds,null);
        redolayoutparams();
    }
    else if(cmdtext == _CommandExpression_LED_UpgradeCNLib){
    }
    else if(cmdtext == _CommandExpression_LED_UpgradeENLib){
        
    }
    else if(cmdtext == _CommandExpression_LED_SetBaudrate){
        reshowledparam();
        cmbparams1 = createNewParamAndShow(EnumParamFieldType.ComboBoxField, _LED_Baudrate, 0, "", new Ext.data.ArrayStore({
            fields: ['valueid', 'val'],
            data: [['0','9600'],['1','19200'],['2','38400'],['3','57600'],['4','115200']]
        }));
        redolayoutparams();
    }
}

var EnumDeviceType = {
    GT30: 0, GT30X: 1, GT60: 2, VT300: 3, VT310: 4, MT80: 5, VT400: 6, MT88: 7, MVT600: 8, MVT100: 9, MVT340: 10, MVT380: 11, T1: 13, MT90: 14, Z21: 15
};

var EnumGPRSCommand = {
    NotSupportThisCommand: 0xFFFF,
    Login_Confirmation: 0x4000,
    Track_on_Demand: 0x4101,
    Track_by_Interval: 0x4102,
    Authorization: 0x4103,
    Overspeed: 0x4105,
    Movement_Alarm: 0x4106,
    GeoFence_Out_Alarm: 0x4107,
    GeoFence_In_Alarm: 0x4207,
    Extended_Settings: 0x4108,
    Initialization: 0x4110, //back to factury default
    Sleep_Mode: 0x4113,
    Output_Control_Limited_Below10kmh_VTOnly: 0x4114,
    Output_Control_Limited_Below20kmh_VTOnly: 0x5114,
    Output_Control_Unlimited_VTOnly: 0x4115,
    Triggered_Alarms: 0x4116,
    
    Power_Down: 0x4126,
    Listen: 0x4130,
    Log_by_Interval: 0x4131,
    Time_Zone: 0x4132,
    Veer_Report: 0x4136,
    //Call_for_SMS: 0x4137,
    CheckEngineFirst:0x4137,
    GPS_Antenna_Cut: 0x4150,
    ChangeIPPortAPN: 0x4155,
    GeoFence_Circle: 0x4302,
    Distance_Interval: 0x4303,
    Clear_Distance: 0x4351,
    Reboot_GPS: 0x4902,
    Heartbeat: 0x5199,
    Format: 0x5503,
    Get_SN_IMEI: 0x9001,
    Read_Interval: 0x9002,
    Read_Authorization: 0x9003,
    Read_Logged_Data: 0x9016,
    Alarms: 0x9999
};

var EnumGTVTSMSCommand = {
    Track_By_SMS: "000",
    Change_Password: "001",
    Track_by_Preset_Interval: "002",
    Authorization: "003",
    LowPower: "004",
    OverSpeed: "005",
    MovementAlarm: "006",
    Extended_Functions: "008",
    Set_DNS_IP: "009",
    Set_Tracker_ID: "010",
    Set_APN: "011",
    Set_IP_Port: "012",
    Set_GPRS_Tracking: "013",
    Set_GPRS_Interval: "014",
    GeoFence_Out_Alarm: "017",
    Output_Unlimit: "020",
    Output_limit_Below10kmh: "120",
    Output_limit_Below20kmh: "220",
    Sleep_Mode: "021",
    Power_Down: "026",
    Listen: "030",
    Log_By_Interval: "031",
    Change_TimeZone: "032",
    Set_SMS_Initials: "033",


    Track_on_Demand: "100",
    GenFence_In_Alarm: "117",
    Shock_Sensor: "035",
    GeoFenceCircle: "302",
    DistanceInterval: "303",
    Set_Prefix: "502",
    Get_Version_Serial: "600",
    Get_IMEI: "601",
    Reboot_GSM: "901",
    Reboot_GPS: "902",
    Initialization: "990",
    Password_Initialization: "999"
};

var EnumMT88Command = {
    Track_on_Demand_only_for_SMS: "A00",
    Track_on_Demand_Google_Link_only_for_SMS: "A01",
    Track_on_interval_and_counter_only_for_SMS: "A02",
    Set_WanDi_Fuel: "A08",
    Track_on_Demand_only_for_GPRS: "A10",
    Set_heart_beat_time_only_for_GPRS: "A11",
    Track_on_interval_and_counter_only_for_GPRS: "A12",
    Track_on_course_change_only_for_GPRS: "A13",
    Track_on_distance_interval: "A14",
    Track_on_interval_when_ignition_off:"A15",
    Check_ignition_onoff: "A16",
    RFID_Control_Out1: "A17",
    Set3D_Shake_Wake_Up:"A19",
    
    Set_GPRS: "A21",
    Set_DNS_Server_IP: "A22",
    Set_Second_GPRS_Server: "A23",
    Track_on_Demand_for_Street_SMS: "A30",
    Read_Auth_NO: "A70",
    Set_Group_Functions_NO: "A71",
    Set_Listening_NO: "A72",
    Set_Smart_Sleep_Mode: "A73",

    Delete_event_and_Get_new_Event_in_memory: "AFF",
    Get_Authorize_phone_number_and_SMS_Event_Flag: "B00",
    Set_Authorize_phone_number_and_SMS_Event_Flag: "B01",

    Add_SMS_Event_Flag: "B02",
    Delete_SMS_Event_Flag: "B03",
    Set_Geo_fence_alert: "B05",
    Delete_Geo_fence_alert: "B06",
    Set_Speeding: "B07",
    Set_tow_alert: "B08",
    Set_Geo_fence_alert_with_Name: "B15",

    Set_extended_functions: "B31",
    Set_GPS_sleep_mode: "B32",
    Set_go_into_sleep_time: "B33",
    Set_interval_for_logging: "B34",
    Set_SMS_time_zone: "B35",
    Set_GPRS_time_zone: "B36",
    Set_Engine_Check:"B60",
    Set_SMS_Header_for_Event: "B91",
    Set_Event_Flag_for_GPRS: "B92",
    Get_Event_Flag_for_GPRS: "B93",
    Set_Event_Flag_for_Taking_Picture: "B96",
    Get_Event_Flag_for_Taking_Picture: "B97",
    Output_control: "C01",
    Send_SMS_From_GPRS: "C02",
    Protocol_control: "C03",
    GPRS_Message: "C10",
    Show_SMS_Content: "C11", //新加
    GRPS_Recieved_Message: "C12",
    GRPS_Send_Message: "C13",
    GRPS_Get_Message: "C14",
    GPS_Open_Close:"C25",
    EXT_Cancel_PulseCalibratio:"C31",
    EXT_InformationCharacter:"C32",
    EXT_SetPrintPeriod:"C33",
    Reg_Ext_Sensor : "C40",
    Del_Ext_Sensor : "C41",
    Get_Ext_Sensor_Info : "C42",
    Set_Ext_Sensor : "C43",
    Get_Ext_Sensor_Details : "C44",
    Set_Fuel_Sensor:"C47",
    Get_Fuel_Sensor:"C48",
    Set_Fuel_Down:"C49",
    
    EXT_LED_Command:"C60",
    
    Get_Image_Data: "D00",
    Get_Image_Names: "D01",
    Delete_Pictures: "D02",
    Take_Picture: "D03",
    Add_RFID: "D10",
    Batch_Auth_RFID: "D11",
    Check_RFID_Auth: "D12",
    Read_Authed_RFID: "D13",
    Delete_Authed_RFID: "D14",
    Batch_Dele_Authed_RFID: "D15",
    Check_RFID_Asyn: "D16",

    Stop_Picture_Sending: "STOP_PIC_SENDING",

    Read_EEP_Data: "E00",
    SetRead_EEP_Ext:"E01",
    Read_Firmware_version_and_SN: "E91",
    Read_logging_waypoints: "E92",
    Reboot_GSM_module: "F01",
    Reboot_GPS_module: "F02",
    //Set_BaseMileage: "F06", // KT Customer defined
    Clear_Record: "F06",
    Set_Record: "F08",
    Remove_Buffer: "F09",
    Initialize_parameters_except_for_password: "F11",
    Change_Password: "F20",
    Initialize_password: "FAB",
    OTA_AUTH: "FC0",
    OTA_SEND_DATA: "FC1",
    OTA_GET_CHECKSUM: "FC2",
    OTA_START: "FC3",
    OTA_CANCEL: "FC4",
    OTA_CHECK: "FC5",
    OTA_CHECK_FILE: "FC6",
    OTA_SET_SERVER: "FC7",
    Set_MLG_GPRS_Server: "FE0",
    Set_MLG_Encrypt: "FF0",
    Quick_Open_GPRS: "F12"
};
var GBCommand = {
    TerminalCommonResponse: 0x0001, //终端通用应答(0x0001)
    TerminalHeartbeat: 0x0002, // 终端心跳(0x0002)
    TerminalUnregist: 0x003, // 终端注销
    TerminalRegist: 0x0100, // 终端注册(0x0100)
    TerminalCheck: 0x0102, //   终端鉴权(0x0102)
    TerminalParamCheckResponse: 0x0104, //查询终端参数应答(0x0104)
    TerminalLocationIntervalResponse: 0x0200, //位置信息汇报(0x0200)
    TerminalLocationCheckResponse: 0x0201, //位置信息查询应答(0x0201)
    TerminalEventReport: 0x0301, //事件报告(0x0301)
    TerminalQuestionResponse: 0x0302, //提问应答(0x0302)
    TerminalMenuResponse: 0x0303, // 信息点播/取消(0x0303)
    TerminalVehicleControlResponse: 0x0500, //车辆控制应答(0x0500)
    TerminalUploadLog: 0x0700, // 行驶记录仪数据上载(0x0700)
    TerminalWayBill: 0x0701,
    TerminalDirverID: 0x0702,
    TerminalMultimediaEvent :0x0800,//多媒体消息上传
    TerminalMultimediaData : 0x0801,//多媒体数据上传
    TerminalSaveBinDataResponse: 0x0802, // 存储图像/视频/音频检索应答(0x0802)
    TerminalTransData: 0x0900,//上行透传
    TerminalSearchBeside: 0x0901, //周边信息查询(0x0901)
    TerminalRSAKey: 0x0A00, //终端RSA公钥(0x0A00)
    
    ServerCommonResponse: 0x8001, //平台通用应答(0x8001)
    RegistResponse: 0x8100, //终端注册应答(0x8100)
    SetTerminalParam: 0x8103, //设置终端参数(0x8103)
    GetTerminalParam: 0x8104, //查询终端参数(0x8104)
    ControlTerminal: 0x8105, // 终端控制(0x8105)
    CheckLocation: 0x8201, //位置信息查询(0x8201)
    TrackingControl: 0x8202, // 位置跟踪控制(0x8202)
    SendText: 0x8300, //文本信息下发(0x8300)
    SetEvent: 0x8301, //事件设置(0x8301)
    SetQuestion: 0x8302, //提问下发(0x8302)
    SetMenu: 0x8303, //信息点播菜单设置(0x8303)
    SetInformation: 0x8304, //信息服务(0x8304)
    SetCallPhone: 0x8400, //电话回拨(0x8400)
    SetPhoneNote: 0x8401, //设置电话本(0x8401)
    VehicleControl: 0x8500,  //车辆控制(0x8500)
    SetCircle: 0x8600, // 设置圆形区域(0x8600)
    DeleteCircle: 0x8601, //删除圆形区域(0x8601)
    SetRectangle: 0x8602, // 设置矩形区域(0x8602)
    DeleteRectangle: 0x8603, //删除矩形区域(0x8603)
    SetPolygon: 0x8604, //设置多边形区域(0x8604)
    DeletePolygon: 0x8605, //删除多边形区域(0x8605)
    SetRoute: 0x8606, //设置路线(0x8606)
    DeleteRoute: 0x8607, //删除路线(0x8607)
    SetUploadLog: 0x8700, //行驶记录仪数据采集命令(0x8700)
    SetLogParam: 0x8701, //  行驶记录仪参数下传命令(0x8701)
    BinDataResponse: 0x8800,  //摄像头图像/视频/音频上传应答(0x8800)
    TakePicture: 0x8801,  //摄像头立即拍摄命令(0x8801)
    SaveBinData: 0x8802, //存储图像/视频/音频检索(0x8802)
    UploadBinData: 0x8803, // 存储图像/视频/音频上传(0x8803)
    BeginRecordVoice: 0x8804, //录音开始命令(0x8804)
    SetBesideInformation: 0x8900, // 周边信息分类菜单设置(0x8900)
    SearchBesideResponse: 0x8901, // 周边信息查询应答(0x8901)
    ElectronicRouteRecordUpload: 0x8902, // 电子路单上报(0x8902)
    DriverInformationUpload: 0x8903, //驾驶员信息采集上报(0x8903)
    DataTransfer: 0x8904, //数据透传(0x8904)
    SetRSAKey: 0x8A00//平台RSA公钥(0x8A00)
};

var EnumLEDCommand = {
    AddNewAdv: 0x0A00,
    DelAdv:0x0A01,
    DelAllAdv:0x0A02,
    GetAdvCount:0x0A03,
    GetOneAdv:0x0A04,
    SendImmeMsg:0x0A05,
    StopImmeMsg:0x0A06,
    SetAlarmMsg:0x0A07,
    ShowAlarmMsg:0x0A08,
    HideAlarmMsg:0x0A09,
    SetDefaultMsg:0x0A0A,
    SetTime:0x0A0B,
    GetTime:0x0A0C,
    SetLightLevel:0x0A0D,
    GetLightLevel:0x0A0E,
    SetPowerOnWaitTime:0x0A0F,
    GetWorkState:0x0A10,
    SetAutoPowerOnOffTime:0x0A11,
    SetLED:0x0A12,
    TestLEDLight:0x0A13,
    UpdateChineseFont:0x0A14,
    UpdateEnglishFont:0x0A15,
    SetBaudrate:0x0A16
};

var responsesearchtimes = 0;
var noresponsesssidArray = [];

function isGT30ProtocolDevice(dtype) {
    if (dtype == EnumDeviceType.GT30 || dtype == EnumDeviceType.GT30X || dtype == EnumDeviceType.GT60 || dtype == EnumDeviceType.VT400 || dtype == EnumDeviceType.VT300 || dtype == EnumDeviceType.VT310)
        return true;
    else
        return false;
}

function isMTProtocolDevice(dtype) {
    if (dtype == EnumDeviceType.MT80 || dtype == EnumDeviceType.MT88 || dtype == EnumDeviceType.MVT100 || dtype == EnumDeviceType.MVT340 || dtype == EnumDeviceType.MVT380 || dtype == EnumDeviceType.MVT600 || dtype == EnumDeviceType.MT90)
        return true;
    else
        return false;
}

//is GB device
function isGBProtocolDevice(dtype) {
    if (dtype == EnumDeviceType.Z21) {
        return true;
    }
    else
        return false;
}

function addOneTCPCommand(sssid, gvvtcommand, gvvtparam, mt88command, mt88param, gbcommand, gbparamdata) {
    responsesearchtimes = 0;
    //noresponsesssidArray = new Array();
    var sssids = "";
    var count = devicestore.getCount();
    var i;
    var nochoose = true;
    i = devicestore.find("sssid", sssid);
    var record = devicestore.getAt(i);
    var devicetype = record.get("devicetype");

    nochoose = false;
    if (isGT30ProtocolDevice(devicetype) && gvvtcommand == EnumGPRSCommand.NotSupportThisCommand) {
        record.set("process", _TrackerMain_NotSupportCommand);
        if(g_OTAWindowObject != null){
            g_OTAWindowObject.changeDisplay(sssid,_TrackerMain_NotSupportCommand);
         }  
        record.set("actionretry", "icon-none");
        record.set("qtipretry", '');
    }
    else if ((isMTProtocolDevice(devicetype)) && mt88command == "") {
        record.set("process", _TrackerMain_NotSupportCommand);
        if(g_OTAWindowObject != null){
            g_OTAWindowObject.changeDisplay(sssid,_TrackerMain_NotSupportCommand);
         }  
        record.set("actionretry", "icon-none");
        record.set("qtipretry", '');
    }
    else if ((isGBProtocolDevice(devicetype)) && gbcommand == null) {
        record.set("process", _TrackerMain_NotSupportCommand);
        if(g_OTAWindowObject != null){
            g_OTAWindowObject.changeDisplay(sssid,_TrackerMain_NotSupportCommand);
         }  
        record.set("actionretry", "icon-none");
        record.set("qtipretry", "");
    }
    else {
        sssids = record.get("sssid");
        if(noresponsesssidArray.indexOf(record.get("sssid")) == -1)
            noresponsesssidArray.push(record.get("sssid")); //add noresponse sssid to array
        record.set("commandid", gvvtcommand);
        record.set("parameters", gvvtparam);
        record.set("process", _TrackerMain_Sending);
        record.set("actionretry", "icon-none");
        record.set("qtipretry", '');
    }

    if (sssids.length > 0) {
        Ext.Ajax.request({
            url: 'HandlerSendCommand',
            method: 'post',
            params: {
                deviceids: sssids,
                commandid: gvvtcommand,
                allparams: gvvtparam,
                newcommand: mt88command,
                newparam: mt88param,
                gbcommand: gbcommand,
                gbparamdata: gbparamdata
            },
            success: function(btn) {
                var val = btn.responseText;
                var count = devicestore.getCount();
                var sssidArray = val.split('|');

                for (i = 0; i < count; i++) {
                    var record = devicestore.getAt(i);
                    var sssid = record.get("sssid");
                    var devicetype = record.get("devicetype");
                    var j;
                    for (j = 0; j < sssidArray.length; j++) {
                        if (sssidArray[j] == sssid) {
                            record.set("process", _TrackerMain_NotOnline);
                            if (g_OTAWindowObject != null) {
                                g_OTAWindowObject.changeDisplay(sssid, _TrackerMain_NotOnline);
                            }
                            if (g_LEDWindowObject != null)
                                g_LEDWindowObject.changeProcess(sssid, _TrackerMain_NotOnline);
                            if (isGT30ProtocolDevice(devicetype)) {
                                record.set("commandid", gvvtcommand);
                                record.set("parameters", gvvtparam);
                            }
                            else if (isMTProtocolDevice(devicetype)) {
                                record.set("commandid", mt88command);
                                record.set("parameters", mt88param);
                            }
                            else if (isGBProtocolDevice(devicetype)) {
                                record.set("commandid", gbcommand);
                                record.set("parameters", gbparamdata);
                            }
                            record.set("actionretry", "icon-resend");
                            record.set("qtipretry", _TrackerMain_Retry);
                            if (mt88command == EnumMT88Command.Del_Ext_Sensor) {
                                Ext.MessageBox.show({
                                    title: record.get('trackername'),
                                    msg: _Message_CannotUnregisterOffline,
                                    buttons: Ext.MessageBox.OK
                                });
                            }
                            else if (mt88command == EnumMT88Command.Set_Ext_Sensor) {
                                Ext.MessageBox.show({
                                    title: record.get('trackername'),
                                    msg: _Message_CannotSetOffline,
                                    buttons: Ext.MessageBox.OK
                                });
                            }
                            noresponsesssidArray.remove(sssid);
                        }
                    }
                }

                if (noresponsesssidArray.length > 0) {
                    window.setTimeout("searchResponseWithStatus()", 3000);
                    //window.setTimeout("searchResponse()", 3000);
                }
            }
        });
    }

}

////send GB message,
//function addGBTCPCommand(messageid, paramdata) {
//
//}

function pushStartEndDateTimeAndSpeedParams(gbParamsArray) {
    var fasf = Ext.getCmp('datetime_gb_start_date');
    if (Ext.getCmp('datetime_gb_start_date')) {
        var s = Ext.getCmp('datetime_gb_start_date').getEl().dom.value +
                         ' ' + Ext.getCmp('datetime_gb_start_time').getEl().dom.value;
        var startDateTime = new Date(Date.parse(s.replace(/-/g, "/")));
        gbParamsArray.push(DateToBCDString(startDateTime));
    }
    if (Ext.getCmp('datetime_gb_end_date')) {
        var s = Ext.getCmp('datetime_gb_end_date').getEl().dom.value +
                         ' ' + Ext.getCmp('datetime_gb_end_time').getEl().dom.value;
        var endDateTime = new Date(Date.parse(s.replace(/-/g, "/")));
        gbParamsArray.push(DateToBCDString(endDateTime));
    }
    if (Ext.getCmp('txt_max_speed')) {
        gbParamsArray.push(UInt16ToWORDString(Ext.getCmp('txt_max_speed').getValue()));
    }
    if (Ext.getCmp('txt_duration')) {
        gbParamsArray.push(parseInt(Ext.getCmp('txt_duration').getValue()).toString(16));
    }
}

function addTCPCommand(gvvtcommand, gvvtparam, mt88command, mt88param, gbcommand, gbparamdata){
    addTCPOrSMSCommand("HandlerSendCommand",gvvtcommand, gvvtparam, mt88command, mt88param, gbcommand, gbparamdata);
}

function addTCPOrSMSCommand(url, gvvtcommand, gvvtparam, mt88command, mt88param, gbcommand, gbparamdata) {//url -SMS or TCP, gvvtcommand -- gtvt command ,gvvtparam -- gvvtparam
    responsesearchtimes = 0;
    var sssids = "";
    var count = devicestore.getCount();
    var i;
    var nochoose = true;
    for (i = 0; i < count; i++) {
        var record = devicestore.getAt(i);
        var choosed = record.get("choosed");
        var sssid = record.get("sssid");
        var devicetype = record.get("devicetype");
        if (choosed) {
            nochoose = false;
            if (isGT30ProtocolDevice(devicetype) && (gvvtcommand == EnumGPRSCommand.NotSupportThisCommand || gvvtcommand == "")) {
                record.set("process", _TrackerMain_NotSupportCommand);
                if(g_OTAWindowObject != null){
                    g_OTAWindowObject.changeDisplay(sssid,_TrackerMain_NotSupportCommand);
                }
                if (g_LEDWindowObject != null)
                    g_LEDWindowObject.changeProcess(sssid,_TrackerMain_NotSupportCommand );
                record.set("actionretry", "icon-none");
                record.set("qtipretry", '');
            }
            else if ((isMTProtocolDevice(devicetype)) && mt88command == "") {
                record.set("process", _TrackerMain_NotSupportCommand);
                if (g_OTAWindowObject != null) {
                    g_OTAWindowObject.changeDisplay(sssid, _TrackerMain_NotSupportCommand);
                }
                if (g_LEDWindowObject != null)
                    g_LEDWindowObject.changeProcess(sssid, _TrackerMain_NotSupportCommand);
                record.set("actionretry", "icon-none");
                record.set("qtipretry", '');
            }
            else if ((isGBProtocolDevice(devicetype)) && gbcommand == null) {
                record.set("process", _TrackerMain_NotSupportCommand);
                if(g_OTAWindowObject != null){
                    g_OTAWindowObject.changeDisplay(sssid,_TrackerMain_NotSupportCommand);
                }
                if (g_LEDWindowObject != null)
                    g_LEDWindowObject.changeProcess(sssid, _TrackerMain_NotSupportCommand);
                record.set("actionretry", "icon-none");
                record.set("qtipretry", "");
            }
            else {
                if (sssids.length == 0) {
                    sssids = record.get("sssid");
                }
                else {
                    sssids += "|" + record.get("sssid");
                }
                if(noresponsesssidArray.indexOf(record.get("sssid")) == -1)
                    noresponsesssidArray.push(record.get("sssid")); //add noresponse sssid to array
                if (isGT30ProtocolDevice(devicetype)) {
                    record.set("commandid", gvvtcommand);
                    record.set("parameters", gvvtparam);
                }
                else if (isMTProtocolDevice(devicetype)) {
                    record.set("commandid", mt88command);
                    record.set("parameters", mt88param);
                }
                else if (isGBProtocolDevice(devicetype)) {
                    record.set("commandid", gbcommand);
                    record.set("parameters", gbparamdata);
                }
                record.set("process", _TrackerMain_Sending);
                record.set("actionretry", "icon-none");
                record.set("qtipretry", '');
            }
        }
    }
    if (sssids.length > 0) {
        Ext.Ajax.request({
            url: url,
            method: 'post',
            params: {
                deviceids: sssids,
                commandid: gvvtcommand,
                allparams: gvvtparam,
                newcommand: mt88command,
                newparam: mt88param,
                gbcommand: gbcommand,
                gbparamdata: gbparamdata
            },
            success: function(btn) {
                if (showSMS) {
                    if (gprsorsmsgroup.getValue().inputValue == 0) {
                        var val = btn.responseText;
                        var count = devicestore.getCount();
                        var sssidArray = val.split('|');
                        for (i = 0; i < count; i++) {
                            var record = devicestore.getAt(i);
                            var sssid = record.get("sssid");
                            var devicetype = record.get("devicetype");
                            var j;
                            for (j = 0; j < sssidArray.length; j++) {
                                if (sssidArray[j] == sssid) {
                                    record.set("process", _TrackerMain_NotOnline);
                                    if(g_OTAWindowObject != null){
                                        g_OTAWindowObject.changeDisplay(sssid,_TrackerMain_NotOnline);
                                    }
                                    if (g_LEDWindowObject != null)
                                        g_LEDWindowObject.changeProcess(sssid, _TrackerMain_NotOnline);
                                    if (isGT30ProtocolDevice(devicetype)) {
                                        record.set("commandid", gvvtcommand);
                                        record.set("parameters", gvvtparam);
                                    }
                                    else if (isMTProtocolDevice(devicetype)) {
                                        record.set("commandid", mt88command);
                                        record.set("parameters", mt88param);
                                    }
                                    else if (isGBProtocolDevice(devicetype)) {
                                        record.set("commandid", gbcommand);
                                        record.set("parameters", gbparamdata);
                                    }
                                    record.set("actionretry", "icon-resend");
                                    record.set("qtipretry", _TrackerMain_Retry);
                                    noresponsesssidArray.remove(sssid);
                                }
                            }
                        }
                        if (noresponsesssidArray.length > 0) {
                            window.setTimeout("searchResponseWithStatus()", 3000);
                        }
                    }
                    else {
                        var val = btn.responseText;
                        var count = devicestore.getCount();
                        var sssidArray = sssids.split('|');
                        if (val == "True") {
                            for (i = 0; i < count; i++) {
                                var record = devicestore.getAt(i);
                                var sssid = record.get("sssid");
                                var j;
                                for (j = 0; j < sssidArray.length; j++) {
                                    if (sssidArray[j] == sssid)
                                        record.set("process", _SMSResource_SendFailed);
                                }
                            }
                        }
                        if (val == "False") {
                            paramIds = sssids.split('|');
                            searchSMSResponseWithStatus();
                        }
                    }
                }
                else {
                    var val = btn.responseText;
                    var count = devicestore.getCount();
                    var sssidArray = val.split('|');
                    for (i = 0; i < count; i++) {
                        var record = devicestore.getAt(i);
                        var sssid = record.get("sssid");
                        var devicetype = record.get("devicetype");
                        var j;
                        for (j = 0; j < sssidArray.length; j++) {
                            if (sssidArray[j] == sssid) {
                                record.set("process", _TrackerMain_NotOnline);
                                if(g_OTAWindowObject != null){
                                        g_OTAWindowObject.changeDisplay(sssid,_TrackerMain_NotOnline);
                                }
                                if (g_LEDWindowObject != null)
                                    g_LEDWindowObject.changeProcess(sssid, _TrackerMain_NotOnline);
                                if (isGT30ProtocolDevice(devicetype)) {
                                    record.set("commandid", gvvtcommand);
                                    record.set("parameters", gvvtparam);
                                }
                                else if (isMTProtocolDevice(devicetype)) {
                                    record.set("commandid", mt88command);
                                    record.set("parameters", mt88param);
                                }
                                else if (isGBProtocolDevice(devicetype)) {
                                    record.set("commandid", gbcommand);
                                    record.set("parameters", gbparamdata);
                                }
                                record.set("actionretry", "icon-resend");
                                record.set("qtipretry", _TrackerMain_Retry);
                                noresponsesssidArray.remove(sssid);
                            }
                        }
                    }
                    if (noresponsesssidArray.length > 0) {
                        window.setTimeout("searchResponseWithStatus()", 3000);
                    }
                }
            }
        });

    }
    if (nochoose) {
        Ext.Msg.show({
            title: _TrackerMain_Title,
            msg: _Message_ChooseOneDevice,
            buttons: Ext.Msg.OK,
            animEl: 'elId',
            icon: Ext.MessageBox.WARNING
        });
    }
};


function addTCPCommandWithDiffParamForMT(sssidArray,mt88commandArray, mt88paramArray) {
    var sssids="";
    var responsesearchtimes = 0;
    var i;
    var mt88commandArrayString = "",mt88paramArrayString="";
    for(i=0;i<sssidArray.length;i++){
        if(noresponsesssidArray.indexOf(sssidArray[i]) == -1)
            noresponsesssidArray.push(sssidArray[i]);
        if(i == 0){
            sssids += sssidArray [i];
            mt88commandArrayString += mt88commandArray[i];
            mt88paramArrayString += mt88paramArray[i];
        }else{
            sssids += "|" + sssidArray[i];
            mt88commandArrayString += "|" +mt88commandArray[i];
            mt88paramArrayString += "|" +mt88paramArray[i];
        }
        var index = devicestore.find('sssid', sssidArray[i]);
        if(index != -1){
            var record = devicestore.getAt(index);
            if (record != null) {
                record.set("process", _TrackerMain_Sending);
                record.set("actionretry", "icon-none");
                record.set("qtipretry", '');
            }
        }
    }
    if (sssids.length > 0) {
        Ext.Ajax.request({
            url: "HandlerSendCommand",
            method: 'post',
            params: {
                deviceids: sssids,
                mt88commandArray: mt88commandArrayString,
                mt88paramArray: mt88paramArrayString
            },
            success: function(btn) {
                var val = btn.responseText;
                var sssidArray = val.split('|');
                for (i = 0; i < devicestore.getCount(); i++) {
                    var record = devicestore.getAt(i);
                    var sssid = record.get("sssid");
                    var devicetype = record.get("devicetype");
                    var j;
                    for (j = 0; j < sssidArray.length; j++) {
                        if (sssidArray[j] == sssid) {
                            record.set("process", _TrackerMain_NotOnline);
                            if(g_OTAWindowObject != null){
                                g_OTAWindowObject.changeDisplay(sssid,_TrackerMain_NotOnline);
                            }
                            if (g_LEDWindowObject != null)
                                g_LEDWindowObject.changeProcess(sssid, _TrackerMain_NotOnline);
                            if (isMTProtocolDevice(devicetype)) {
                                record.set("commandid", mt88commandArray[j]);
                                record.set("parameters", mt88paramArray[j]);
                            }
                            record.set("actionretry", "icon-resend");
                            record.set("qtipretry", _TrackerMain_Retry);
                            noresponsesssidArray.remove(sssid);
                        }
                    }
                }
                if (noresponsesssidArray.length > 0) {
                    window.setTimeout("searchResponseWithStatus()", 3000);
                }
            }
        });

    }
    
};

function addSingleTCPCommand(record) {
    responsesearchtimes = 0;
    var sssids = record.get("sssid");
    var commandtype = record.get("commandid");
    var param = record.get("parameters");
    record.set("process", _TrackerMain_Sending);
    record.set("actionretry", "icon-none");
    record.set("qtipretry", '');
    if (sssids.length > 0) {
        Ext.Ajax.request({
            url: 'HandlerSendCommand',
            method: 'post',
            params: {
                deviceids: sssids,
                commandid: commandtype,
                allparams: param
            },
            success: function(btn) {
                var val = btn.responseText;
                var count = devicestore.getCount();
                var sssidArray = val.split('|');
                for (i = 0; i < count; i++) {
                    var record = devicestore.getAt(i);
                    var sssid = record.get("sssid");
                    var j;
                    for (j = 0; j < sssidArray.length; j++) {
                        if (sssidArray[j] == sssid) {
                            record.set("process", _TrackerMain_NotOnline);
                            if(g_OTAWindowObject != null){
                                g_OTAWindowObject.changeDisplay(sssid,_TrackerMain_NotOnline);
                            }
                            if (g_LEDWindowObject != null)
                                g_LEDWindowObject.changeProcess(sssid, _TrackerMain_NotOnline);
                            record.set("commandid", commandtype);
                            record.set("parameters", param);
                            record.set("actionretry", "icon-resend");
                            record.set("qtipretry", _TrackerMain_Retry);
                            noresponsesssidArray.remove(sssid);
                        }
                    }
                }

                if (noresponsesssidArray.length > 0) {
                    window.setTimeout("searchResponseWithStatus()", 3000);
                    //window.setTimeout("searchResponse()",3000);
                }
            }
        });
    }
    else {
        Ext.Msg.show({
            title: _TrackerMain_Title,
            msg: _Message_ChooseOneDevice,
            buttons: Ext.Msg.OK,
            animEl: 'elId',
            icon: Ext.MessageBox.WARNING
        });
    }
};

var searchresponsewithstatusreader = new Ext.data.JsonReader({}, [
   { name: 'sssid' },
   { name: 'commandid' },
   { name: 'responsetext' },
   { name: 'status', type: 'int' },
   { name: 'trackername' }
]);

var searchresponsewithstatusproxy = new Ext.data.HttpProxy({
    method: 'post',
    url: 'HandlerSearchResponseWithStatus'
});




var searchresponsewithstatusstore = new Ext.data.Store({
    autoSave: true,
    reader: searchresponsewithstatusreader,
    proxy: searchresponsewithstatusproxy,
    sortInfo: { field: 'sssid', direction: "ASC" }
});


var searchsmsresponsewithstatusstore = new Ext.data.Store({
    autoSave: true,
    reader: searchresponsewithstatusreader,
    proxy: new Ext.data.HttpProxy({
        method: 'post',
        url: 'HandlerSearchSMSRsponse'
    }),
    sortInfo: { field: 'sssid', direction: "ASC" }
});


// this function search the communication response for all device
var searchTimer = null;
function searchResponseWithStatus() {
    if (noresponsesssidArray.length > 0) {
        //if has no response id
        responsesearchtimes++;
        var sssids = "";
        var i;
        for (i = 0; i < noresponsesssidArray.length; i++) {
            if (sssids.length == 0) {
                sssids = noresponsesssidArray[i];
            }
            else
                sssids += "|" + noresponsesssidArray[i];
        }
        searchresponsewithstatusstore.baseParams = { deviceids: sssids };
        searchresponsewithstatusstore.reload({
            callback: function() {
                var responsecount = searchresponsewithstatusstore.getCount();
                var i;
                for (i = 0; i < responsecount; i++) {
                    var record = searchresponsewithstatusstore.getAt(i);
                    var sssid = record.get("sssid");
                    var status = record.get("status");
                    var commandid = record.get("commandid");
                    var responsetext = record.get("responsetext");
                    var trackername = record.get("trackername");
                    var devicecount = devicestore.getCount();
                    var j;
                    for (j = 0; j < devicecount; j++) {
                        var tmprecord = devicestore.getAt(j);
                        var tmpsssid = tmprecord.get("sssid");
                        var tmpprocess = tmprecord.get("process");
                        if (tmpsssid == sssid) {//&& tmpprocess == _TrackerMain_Sending) {
                            if (status != 0) {
                                noresponsesssidArray.remove(tmpsssid); //already has response
                                if (status == -2) {
                                    tmprecord.set("process", _TrackerMain_TimeOut);

                                    if (g_OTAWindowObject != null) {
                                        g_OTAWindowObject.changeDisplay(sssid, _TrackerMain_TimeOut);
                                    }
                                    if (g_LEDWindowObject != null)
                                        g_LEDWindowObject.changeProcess(sssid, _TrackerMain_TimeOut);
                                    if (commandid == EnumMT88Command.Del_Ext_Sensor) {
                                        Ext.MessageBox.show({
                                            title: trackername,
                                            msg: _Message_CannotUnregisterOffline,
                                            buttons: Ext.MessageBox.OK
                                        });
                                    }
                                    else if (commandid == EnumMT88Command.Set_Ext_Sensor) {
                                        Ext.MessageBox.show({
                                            title: trackername,
                                            msg: _Message_CannotSetOffline,
                                            buttons: Ext.MessageBox.OK
                                        });
                                    }

                                    tmprecord.set("actionretry", "icon-resend");
                                    tmprecord.set("qtipretry", _TrackerMain_Retry);
                                }
                                else if (status == -1000) {
                                    tmprecord.set("process", _TrackerMain_NotOnline);
                                    if (g_OTAWindowObject != null) {
                                        g_OTAWindowObject.changeDisplay(sssid, _TrackerMain_NotOnline);
                                    }
                                    if (g_LEDWindowObject != null)
                                        g_LEDWindowObject.changeProcess(sssid, _TrackerMain_NotOnline);
                                    if (commandid == EnumMT88Command.Del_Ext_Sensor) {
                                        Ext.MessageBox.show({
                                            title: trackername,
                                            msg: _Message_CannotUnregisterOffline,
                                            buttons: Ext.MessageBox.OK
                                        });
                                    }
                                    else if (commandid == EnumMT88Command.Set_Ext_Sensor) {
                                        Ext.MessageBox.show({
                                            title: trackername,
                                            msg: _Message_CannotSetOffline,
                                            buttons: Ext.MessageBox.OK
                                        });
                                    }

                                    tmprecord.set("actionretry", "icon-resend");
                                    tmprecord.set("qtipretry", _TrackerMain_Retry);
                                }
                                else if (status == 1) {
                                    var isnewprotocol = isNaN(commandid);
                                    if (!isnewprotocol) {
                                        var cmdid = parseInt(commandid, 16);

                                        if (cmdid == EnumGPRSCommand.Read_Interval) {
                                            tmprecord.set("process", responsetext);
                                            addNewInfo(trackername, responsetext);
                                        }
                                        else if (cmdid == EnumGPRSCommand.Read_Authorization) {
                                            tmprecord.set("process", responsetext);
                                            addNewInfo(trackername, responsetext);
                                        }
                                        else if (cmdid == EnumGPRSCommand.Get_SN_IMEI) {
                                            tmprecord.set("process", responsetext);
                                            addNewInfo(trackername, responsetext);
                                        }
                                        else {
                                            var stxt = getCommandStringFromCommandID(cmdid) + " " + _TrackerMain_Received;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                    }
                                    else {
                                        if (responsetext == "PICOK") {
                                            tmprecord.set("process", _TrackerMain_GetPictureOK);
                                        }
                                        else if (responsetext == 'FFFF') {
                                            var stxt = getCommandStringFromCommandID(commandid) + " " + _Err_Param;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                        else if (responsetext == 'FFFE') {
                                            var stxt = getCommandStringFromCommandID(commandid) + " " + _Err_NotSupport;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                        else if (responsetext == 'FFFD') {

                                        }
                                        else if (responsetext == 'FFF7') {
                                            var stxt = getCommandStringFromCommandID(commandid) + " " + _Err_Command;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }

                                        else if (commandid == EnumMT88Command.Read_Firmware_version_and_SN) {
                                            tmprecord.set("process", responsetext);
                                            addNewInfo(trackername, responsetext);
                                            var tmp = responsetext.split(',');
                                            if (g_OTAWindowObject != null) {
                                                g_OTAWindowObject.changeOldFirmware(sssid, tmp[0]);
                                                g_OTAWindowObject.changeDisplay(sssid, _TrackerMain_Received);
                                            }
                                        }
                                        else if (commandid == EnumMT88Command.Get_Fuel_Sensor) {
                                            tmprecord.set("process", responsetext);
                                            addNewInfo(trackername, responsetext);
                                            var tmp = responsetext.split(',');
                                            if (g_FuelSensorWindowObject != null) {
                                                g_FuelSensorWindowObject.changeDisplay(sssid, tmp);
                                            }
                                        }
                                        else if (commandid == EnumMT88Command.Get_Event_Flag_for_GPRS) {
                                            var gprsAuth = new GPRSAuthWindow(sssid, trackername, responsetext, false);
                                            var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received + ':' + responsetext;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                        else if (commandid == EnumMT88Command.Get_Event_Flag_for_Taking_Picture) {
                                            var photoAuth = new GPRSAuthWindow(sssid, trackername, responsetext, true);
                                            var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received + ':' + responsetext;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                        else if (commandid == EnumMT88Command.Get_Authorize_phone_number_and_SMS_Event_Flag) {
                                            var smsauth = new SMSAuthWindow();
                                            smsauth.beginSetAuth(sssid, trackername, responsetext);
                                            var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received + ':' + responsetext;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                        else if (commandid == EnumMT88Command.Take_Picture) {
                                            if (responsetext == "Error") {
                                                //快照失败
                                                addNewInfo(trackername, getCommandStringFromCommandID(commandid) + stxt);
                                            }
                                        }
                                        else if (commandid == EnumMT88Command.Get_Image_Names) {

                                            if (g_PhotoWindowDictionary.ContainsKey(sssid)) {
                                                var tmpwin = g_PhotoWindowDictionary.Item(sssid);
                                                tmpwin.hide();
                                            }
                                            var photolist = new PhotoListWindow(sssid, trackername, responsetext);
                                            g_PhotoWindowDictionary.Add(sssid, photolist);
                                            var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                        else if (commandid == EnumMT88Command.Get_Image_Data) {
                                            var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                            if (g_PhotoWindowDictionary.ContainsKey(sssid)) {
                                                var tmpwin = g_PhotoWindowDictionary.Item(sssid);
                                                tmpwin.completeUploadImg();
                                            }
                                            new Ext.Window({
                                                title: trackername + " " + responsetext,
                                                autoScroll: true,
                                                width: 660,
                                                height: 520,
                                                plain: true,
                                                constrain: true,
                                                html: "<img src='HandlerGetPictureByIMEIFileName?sssid=" + escape(sssid) + "&filename=" + responsetext + "'></img>"
                                            }).show();
                                        }
                                        else if (commandid == EnumMT88Command.Delete_Pictures) {

                                            var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                            //addOneTCPCommand(sssid, EnumGPRSCommand.NotSupportThisCommand, '', EnumMT88Command.Get_Image_Names, '0');
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                            Ext.Ajax.request({
                                                url: 'HandlerGetImageNameList',
                                                method: 'post',
                                                params: {
                                                    sssid: sssid,
                                                    trackername: trackername
                                                },
                                                success: function(r) {
                                                    var responsetext = r.responseText;
                                                    var p = responsetext.split(':');
                                                    if (p.length == 3) {
                                                        if (g_PhotoWindowDictionary.ContainsKey(p[0])) {
                                                            var tmpwin = g_PhotoWindowDictionary.Item(p[0]);
                                                            tmpwin.hide();
                                                        }
                                                        var photolist = new PhotoListWindow(p[0], p[1], p[2]);
                                                        g_PhotoWindowDictionary.Add(p[0], photolist);
                                                    }
                                                }
                                            });
                                        }
                                        else if (commandid == EnumMT88Command.Read_Authed_RFID) {
                                            if (g_RFIDWindowDictionary.ContainsKey(sssid)) {
                                                var tmpwin = g_RFIDWindowDictionary.Item(sssid);
                                                tmpwin.close();
                                            }
                                            var rfidlistwin = new RFIDAuthWindow(sssid, trackername, responsetext, true, null);
                                            g_RFIDWindowDictionary.Add(sssid, rfidlistwin);
                                            var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                        else if (commandid == EnumMT88Command.Read_Auth_NO) {
                                            var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received + ':' + responsetext;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                        else if (commandid == EnumMT88Command.Check_RFID_Auth) {
                                            if (responsetext == "0") {
                                                tmprecord.set("process", _TrackerMain_Unauthorized);
                                            }
                                            else {
                                                tmprecord.set("process", _TrackerMain_Authorized);
                                            }
                                        }
                                        else if (commandid == EnumMT88Command.GRPS_Recieved_Message) {
                                            var p = responsetext.split(',');
                                            if (p.length >= 4) {
                                                var level = p[0];
                                                var flag = p[1];
                                                var code = p[2];
                                                var txt = p[3];
                                                var mwinclass = new GPRSMessageReceivedWin(trackername, flag, level, txt, sssid);

                                                mwinclass.messagewin.show();
                                            }
                                        }

                                        else if (commandid == EnumMT88Command.Reg_Ext_Sensor) {
                                            var tmp = responsetext.split(',');
                                            var m;
                                            if (responsetext.length > 0) {
                                                for (m = 0; m < tmp.length; m++) {
                                                    var tmp2 = tmp[m].split('|');
                                                    if (tmp2.length == 3) {
                                                        if (tmp2[2] == "3") {
                                                            Ext.MessageBox.show({
                                                                title: trackername,
                                                                msg: tmp2[1] + ":" + _Message_TemperatureSensorFull,
                                                                buttons: Ext.MessageBox.OK
                                                            });
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        else if (commandid == EnumMT88Command.Del_Ext_Sensor) {
                                            var tmp = responsetext.split(',');
                                            var failednumber = "";
                                            for (var i = 0; i < tmp.length / 2; i++) {
                                                if (tmp[i * 2 + 1] == 3) {
                                                    failednumber += "," + tmp[i];
                                                }
                                                else if (tmp[i * 2 + 1] == 1 || tmp[i * 2 + 1] == 2) {
                                                    if (g_ExtSensorWindowObject != null) {
                                                        g_ExtSensorWindowObject.removeSensor(sssid, tmp[i * 2]);
                                                    }
                                                }
                                            }
                                            if (failednumber.length > 0) {
                                                Ext.MessageBox.show({
                                                    title: trackername,
                                                    msg: failednumber + _Message_UnregisterFailed,
                                                    buttons: Ext.MessageBox.OK
                                                });
                                            }
                                            else {
                                                Ext.MessageBox.show({
                                                    title: trackername,
                                                    msg: _Message_UnregisterOK,
                                                    buttons: Ext.MessageBox.OK
                                                });
                                            }
                                            //                                            if(tmp.length == 2){
                                            //                                                if(tmp[1] == "OK"){
                                            //                                                    Ext.MessageBox.show({
                                            //                                                        title: trackername,
                                            //                                                        msg:tmp[0]+":"+ _Message_UnregisterOK,
                                            //                                                        buttons: Ext.MessageBox.OK
                                            //                                                    });
                                            //                                                }
                                            //                                            }
                                            //                                            else{
                                            //                                                if(tmp == "Err"){
                                            //                                                    Ext.MessageBox.show({
                                            //                                                        title: trackername,
                                            //                                                        msg:_Message_UnregisterFailed,
                                            //                                                        buttons: Ext.MessageBox.OK
                                            //                                                    });
                                            //                                                }
                                            //                                            }
                                        }
                                        else if (commandid == EnumMT88Command.OTA_START) {
                                            tmprecord.set("process", responsetext);
                                            var s = responsetext;
                                            if (responsetext == "OTAWRITTING")
                                                s = _Message_OTA_Writing;
                                            else if (responsetext.indexOf("OTASUCCESS") == 0) {
                                                s = _Message_OTA_Success;
                                                var tmp = responsetext.split('|');
                                                if (tmp.length == 2) {
                                                    if (g_OTAWindowObject != null) {
                                                        g_OTAWindowObject.changeOldFirmware(sssid, tmp[1]);
                                                    }
                                                }
                                            }
                                            else if (responsetext == "OTAFAILED")
                                                s = _Message_OTA_WriteFailed;
                                            if (g_OTAWindowObject != null) {
                                                if (s == _Message_OTA_WriteFailed)
                                                    g_OTAWindowObject.changeUpgradeProgress(sssid, 100, 0);
                                                else
                                                    g_OTAWindowObject.changeUpgradeProgress(sssid, 100, 100);
                                                g_OTAWindowObject.changeDisplay(sssid, s);
                                            }
                                        }
                                        else if (commandid == EnumMT88Command.OTA_CHECK) {
                                            tmprecord.set("process", responsetext);
                                            //                                            if(g_OTAWindowObject != null){
                                            //                                                g_OTAWindowObject.changeDisplay(sssid,responsetext);
                                            //                                            }
                                        }

                                        else if (commandid == EnumMT88Command.OTA_CANCEL) {
                                            tmprecord.set("process", _TrackerMain_Cancel);
                                            if (g_OTAWindowObject != null) {
                                                g_OTAWindowObject.changeDisplay(sssid, _TrackerMain_Cancel);
                                            }
                                        }
                                        else if (commandid == EnumMT88Command.SetRead_EEP_Ext) {
                                            var tmp1 = responsetext.substr(0, 2);
                                            var tmpdata = responsetext.substr(2, responsetext.length - 2);
                                            if (tmp1 == "00") {
                                                //写入回复
                                                var pewin;
                                                if (g_PEWindowDictionary.ContainsKey(sssid))
                                                    pewin = g_PEWindowDictionary.Item(sssid);
                                                else {
                                                    pewin = new ParamEditorWin(sssid, trackername);
                                                    g_PEWindowDictionary.Add(sssid, pewin);
                                                }
                                                pewin.AnalyzE01Data(0,tmpdata);
                                                var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                                tmprecord.set("process", stxt);
                                                addNewInfo(trackername, stxt);
                                            }
                                            else if (tmp1 == "01") {
                                                //读取回复值
                                                var pewin;
                                                if (g_PEWindowDictionary.ContainsKey(sssid))
                                                    pewin = g_PEWindowDictionary.Item(sssid);
                                                else {
                                                    pewin = new ParamEditorWin(sssid, trackername);
                                                    g_PEWindowDictionary.Add(sssid,pewin);
                                                }
                                                pewin.AnalyzE01Data(1,tmpdata);
                                                var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                                tmprecord.set("process", stxt);
                                                addNewInfo(trackername, stxt);
                                            }
                                        }
                                        else if (commandid == "RGF") {
                                            if (responsetext == "") {
                                                tmprecord.set("process", _TrackerMain_NoGeoFence);
                                                addNewInfo(trackername, _TrackerMain_NoGeoFence);
                                            }
                                            else {
                                                var gdata = responsetext.split('|');

                                                var i;
                                                var geofencearray = new Array();
                                                for (i = 0; i < gdata.length; i++) {
                                                    var tmp = gdata[i].split(',');
                                                    var geofence = new Object();
                                                    geofence.longitude = tmp[0];
                                                    geofence.latitude = tmp[1];
                                                    geofence.radius = tmp[2];
                                                    geofence.inalarm = tmp[3];
                                                    geofence.outalarm = tmp[4];
                                                    geofence.index = tmp[5];
                                                    geofencearray.push(geofence);
                                                }
                                                var win = createGeoFenceMapWindow(trackername);

                                                win.show(); // 显示出来

                                                var rmap = createMap(win.getMap(), true, null, gmapurl);
                                                nextwindowx += 20;
                                                nextwindowy += 20;
                                                rmap.drawAllCircleGeoFence(geofencearray);
                                                addNewInfo(trackername, _TrackerMain_Received);
                                                tmprecord.set("process", _TrackerMain_Received);
                                            }
                                        }
                                        else if (commandid == "RIP") {
                                            var tmp = responsetext.split(',');
                                            var stxt = _TrackerMain_IP + "1:" + tmp[0] + "," + _TrackerMain_Port + "1:" + tmp[1] + "," + _TrackerMain_IP + "2:" + tmp[2] + "," + _TrackerMain_Port + "2:" + tmp[3];
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                        else if (commandid == "RCS") {
                                            var tmp = responsetext.split(',');
                                            var stxt = _TrackerMain_Interval + ":" + tmp[0] + _TrackerMain_Counter + ":" + tmp[1] + ",APN:" + tmp[2];
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                        else if (commandid.indexOf("LED") == 0) {
                                            var ledres = responsetext;
                                            if (ledres == "NoAnswer") {
                                                tmprecord.set("process", _LED_NoResponse);
                                                if (g_LEDWindowObject != null)
                                                    g_LEDWindowObject.changeProcess(sssid, _LED_NoResponse);
                                                return;
                                            }
                                            if (commandid == "LED8A00") {
                                                var tmp = responsetext.split(',');
                                                if (tmp[0] == "OK") {
                                                    var stxt = _LED_AdvAdd + ":" + tmp[1] + _CommandExpression_SetOK;
                                                    tmprecord.set("process", stxt);
                                                    addNewInfo(trackername, stxt);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, stxt);
                                                }
                                                else {
                                                    var stxt = _LED_AdvAdd + _TAResources_Failure;
                                                    tmprecord.set("process", stxt);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, stxt);
                                                    addNewInfo(trackername, stxt);
                                                }
                                            }
                                            else if (commandid == "LED8A03") {
                                                var tmp = responsetext.split(',');
                                                if (tmp[0] == "OK") {
                                                    var mailadds = "";
                                                    for (var a = 2; a < tmp.length; a++)
                                                        mailadds += (mailadds.length > 0 ? "," + tmp[a] : tmp[a]);
                                                    var stxt = _LED_InfoCount + ":" + tmp[1] + " " + _LED_MailboxNumber + mailadds;
                                                    tmprecord.set("process", stxt);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, stxt);
                                                    addNewInfo(trackername, stxt);
                                                }
                                                else {
                                                    tmprecord.set("process", _LED_ReadErr);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, _LED_ReadErr);
                                                    addNewInfo(trackername, _LED_ReadErr);
                                                }
                                            }
                                            else if (commandid == "LED8A04") {
                                                tmprecord.set("process", responsetext);
                                                if (g_LEDWindowObject != null)
                                                    g_LEDWindowObject.changeProcess(sssid, _TrackerMain_Received);
                                                addNewInfo(trackername, responsetext);
                                                var ttt = responsetext.split('#');
                                                var tmp = ttt[0].split(',');
                                                if (tmp[0] == "OK") {
                                                    var ledadvfield = [
                                                        "sssid",
                                                        "trackername",
                                                        { name: "adv_address", type: "integer" },
                                                        { name: "font", type: "integer" },
                                                        { name: "color", type: "integer" },
                                                        { name: "moving", type: "integer" },
                                                        { name: "speed", type: "integer" },
                                                        { name: "stay_time", type: "integer" },
                                                        { name: "stop_model", type: "integer" },
                                                        { name: "showtimes", type: 'integer' },
                                                        { name: "usealllife", type: 'boolean' },
                                                        { name: "start_date", type: "datetime" },
                                                        { name: "stop_date", type: "datetime" },
                                                        { name: "msg_show_time_span", type: "int" },
                                                        "timespans",
                                                        "text",
                                                        "advname"
                                                    ];
                                                    var usealllife = (tmp[9] == "1" ? true : false);
                                                    var tt = tmp[10].split('|');
                                                    var startdate = tt[0];
                                                    var stopdate = tt[1];
                                                    var timespans = tmp[12];
                                                    var tmpstore = new Ext.data.ArrayStore({
                                                        fields: ledadvfield,
                                                        data: [[sssid, trackername, parseInt(tmp[1]), parseInt(tmp[2]), parseInt(tmp[3]), parseInt(tmp[4]), parseInt(tmp[5]), parseInt(tmp[6]), parseInt(tmp[7]), parseInt(tmp[8]), usealllife, startdate, stopdate, tmp[11], timespans, tmp[13], ttt.length > 0 ? ttt[1] : ""]]
                                                    });

                                                    var sssidarray = [];
                                                    var advaddressarray = [];
                                                    var record = tmpstore.getAt(0);
                                                    sssidarray.push(record.get('sssid'));
                                                    advaddressarray.push(record.get('adv_address'));

                                                    addnewledadvwin(sssidarray, advaddressarray, record);
                                                }
                                                else {
                                                    tmprecord.set("process", _LED_ReadErr);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, _LED_ReadErr);
                                                    addNewInfo(trackername, _LED_ReadErr);
                                                }
                                            }
                                            else if (commandid == "LED8A0C") {
                                                var tmp = responsetext.split(',');
                                                if (tmp[0] == "OK") {
                                                    var stxt = _LED_Time + ":" + tmp[1];
                                                    tmprecord.set("process", stxt);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, stxt);
                                                    addNewInfo(trackername, stxt);
                                                }
                                                else {
                                                    tmprecord.set("process", _LED_ReadErr);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, _LED_ReadErr);
                                                    addNewInfo(trackername, _LED_ReadErr);
                                                }
                                            }
                                            else if (commandid == "LED8A0E") {
                                                var tmp = responsetext.split(',');
                                                if (tmp[0] == "OK") {
                                                    var stxt = _LED_LightValue + ":" + tmp[2];
                                                    tmprecord.set("process", stxt);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, stxt);
                                                    addNewInfo(trackername, stxt);
                                                }
                                                else {
                                                    tmprecord.set("process", _LED_ReadErr);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, _LED_ReadErr);
                                                    addNewInfo(trackername, _LED_ReadErr);
                                                }
                                            }
                                            else if (commandid == "LED8A10") {
                                                var tmp = responsetext.split(',');
                                                if (tmp[0] == "OK") {
                                                    var txtshownow = "";
                                                    var t = parseInt(tmp[3]);
                                                    if (t < 1000)
                                                        txtshownow = tmp[3];
                                                    else if (t == 1000)
                                                        txtshownow = _LED_DefaultText;
                                                    else if (t == 1001)
                                                        txtshownow = _LED_Time;
                                                    else if (t == 1006)
                                                        txtshownow = _LED_Alarm;
                                                    else if (t == 1007)
                                                        txtshownow = _LED_Immi;
                                                    var stxt = (tmp[1] == "0" ? _LED_BlackScreen : _LED_LightScrren) + "," + _LED_InfoCount + ":" + tmp[2] + "," + _LED_ShowNow + ((t < 1000) ? "(" + _LED_MailboxNumber + ")" : "") + ":" + txtshownow;
                                                    tmprecord.set("process", stxt);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, stxt);
                                                    addNewInfo(trackername, stxt);
                                                }
                                                else {
                                                    tmprecord.set("process", _LED_ReadErr);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, _LED_ReadErr);
                                                    addNewInfo(trackername, _LED_ReadErr);
                                                }
                                            }
                                            else {
                                                var tmp = responsetext.split(',');
                                                if (tmp[0] == "OK") {
                                                    tmprecord.set("process", _CommandExpression_SetOK);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, _CommandExpression_SetOK);
                                                    addNewInfo(trackername, _CommandExpression_SetOK);
                                                }
                                                else {
                                                    tmprecord.set("process", _TAResources_Failure);
                                                    if (g_LEDWindowObject != null)
                                                        g_LEDWindowObject.changeProcess(sssid, _TAResources_Failure);
                                                    addNewInfo(trackername, _TAResources_Failure);
                                                }
                                            }
                                        }
                                        /**************************越南定制**************************/

                                        //------------国标--------------------------------//
                                        else if (commandid == "GB0104" || commandid == "GB0301" || commandid == "GB0302" || commandid == "GB0303" || commandid == "GB0700" || commandid == "GB0701" || commandid == "GB0702" || commandid == "GB0800" || commandid == "GB0801" | commandid == "GB0802") {

                                            //alert(responsetext);
                                            if (commandid == "GB0104") {
                                                var p = new GBTrackerSettingsWindow(trackername, responsetext);

                                            }
                                            else if (commandid == "GB0302") {

                                                var tmp = responsetext.split('|');
                                                Ext.MessageBox.show({
                                                    title: trackername,
                                                    msg: "问题:" + tmp[0] + "     回答:" + tmp[1],
                                                    buttons: Ext.MessageBox.OK
                                                });
                                            }
                                            else if (commandid == "GB0700") {
                                                //行驶记录
                                                var logcmdid = responsetext.substr(0, 2);
                                                var body = responsetext.substr(3, responsetext.length - 3);
                                                if (logcmdid == "01") {
                                                    var drivercodeid = transGBHexToString(body);
                                                    var drivercode = drivercodeid.substr(0, 3);
                                                    var driverid = drivercodeid.substr(3, drivercodeid.length - 3);
                                                    Ext.MessageBox.show({
                                                        title: trackername,
                                                        msg: "驾驶员代码:" + drivercode + "     驾驶证:" + driverid,
                                                        buttons: Ext.MessageBox.OK
                                                    });
                                                }
                                                else if (logcmdid == "02") {
                                                    var dd = body.split(',');
                                                    Ext.MessageBox.show({
                                                        title: trackername,
                                                        msg: (2000 + parseInt(dd[0], 10)).toString() + "-" + dd[1].toString() + "-" + dd[2].toString() + " " + dd[3].toString() + ":" + dd[4].toString() + ":" + dd[5].toString(),
                                                        buttons: Ext.MessageBox.OK
                                                    });
                                                }
                                                else if (logcmdid == "03" || logcmdid == "08") {
                                                    var dd = body.split(',');
                                                    var odo = (parseFloat(dd[0].toString() + dd[1].toString() + dd[2].toString()) * 0.1).toFixed(2); //里程
                                                    var time = (2000 + parseInt(dd[3], 10)).toString() + "-" + dd[4].toString() + "-" + dd[5].toString() + " " + dd[6].toString() + ":" + dd[7].toString();
                                                    Ext.MessageBox.show({
                                                        title: trackername,
                                                        msg: "采集时间:" + time + " 行驶里程:" + odo,
                                                        buttons: Ext.MessageBox.OK
                                                    });
                                                }
                                                else if (logcmdid == "04") {
                                                    var dd = body.split(',');
                                                    var sid = parseInt(dd[0].toString() + dd[1].toString() + dd[2].toString(), 16); //里程
                                                    Ext.MessageBox.show({
                                                        title: trackername,
                                                        msg: "特征系数:" + sid,
                                                        buttons: Ext.MessageBox.OK
                                                    });

                                                }
                                                else if (logcmdid == "05" || logcmdid == "09") {
                                                    if (g_GBCollectionWindowDictionary.ContainsKey(sssid)) {
                                                        var tmpwin = g_GBCollectionWindowDictionary.Item(sssid);
                                                        tmpwin.close();
                                                    }
                                                    var gbwin = new GBCollectionWindow(sssid, trackername, body, false);
                                                    g_GBCollectionWindowDictionary.Add(sssid, gbwin);

                                                }
                                                else if (logcmdid == "06") {
                                                    var dd = body.split(',');
                                                    Ext.MessageBox.show({
                                                        title: trackername,
                                                        msg: "VIN:" + dd[0] + " 车牌号:" + dd[1] + " 车牌类型:" + dd[2],
                                                        buttons: Ext.MessageBox.OK
                                                    });
                                                }
                                                else if (logcmdid == "07") {
                                                    if (g_GBCollectionWindowDictionary.ContainsKey(sssid)) {
                                                        var tmpwin = g_GBCollectionWindowDictionary.Item(sssid);
                                                        tmpwin.close();
                                                    }
                                                    var gbwin = new GBCollectionWindow(sssid, trackername, body, true);
                                                    g_GBCollectionWindowDictionary.Add(sssid, gbwin);
                                                }
                                                else if (logcmdid == "11") {
                                                    var dd = body.split(',');
                                                    var drvierid = dd[0];
                                                    if (dd.length > 1) {
                                                        var overtimestr = "";
                                                        var i;

                                                        for (i = 0; i < (dd.length - 1) / 2; i++)
                                                            overtimestr += "起始时间:" + dd[1 + i * 2] + " 结束时间:" + dd[2 + i * 2];
                                                        Ext.MessageBox.show({
                                                            title: trackername + " 2天内3小时超时驾驶",
                                                            msg: overtimestr,
                                                            buttons: Ext.MessageBox.OK
                                                        });
                                                    }
                                                    else {
                                                        Ext.MessageBox.show({
                                                            title: trackername + " 2天内无超时驾驶",
                                                            msg: overtimestr,
                                                            buttons: Ext.MessageBox.OK
                                                        });
                                                    }
                                                }
                                                var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                                tmprecord.set("process", stxt);
                                                addNewInfo(trackername, stxt);
                                            }
                                            else if (commandid == "GB0701") {
                                                //电子运单
                                                var len = GBStringToUInt32(responsetext.substr(0, 11));
                                                Ext.MessageBox.show({
                                                    title: trackername + " 电子运单上报",
                                                    msg: responsetext.substr(12, responsetext.length - 12),
                                                    buttons: Ext.MessageBox.OK
                                                });
                                            }
                                            else if (commandid == "GB0702") {
                                                //驾驶员身份
                                                var dd = responsetext.split(',');
                                                Ext.MessageBox.show({
                                                    title: trackername,
                                                    msg: "姓名:" + dd[0] + " 身份证:" + dd[1] + " 从业资格证:" + dd[2] + " 发证机构:" + dd[3],
                                                    buttons: Ext.MessageBox.OK
                                                });
                                            }
                                            else if (commandid == "GB0800") {

                                            }
                                            else if (commandid == "GB0802") {
                                            }
                                        }

                                        else {
                                            var stxt = _TrackerMain_Received;
                                            if (responsetext == 'FFFF') {
                                                stxt = _Err_Param;
                                            }
                                            else if (responsetext == 'FFFE') {
                                                stxt = _Err_NotSupport;
                                            }
                                            else if (responsetext == 'FFFD') {

                                            }
                                            else if (responsetext == 'FFF7') {
                                                stxt = _Err_Command;
                                            }
                                            var stxt = getCommandStringFromCommandID(commandid) + " " + stxt;
                                            tmprecord.set("process", stxt);
                                            addNewInfo(trackername, stxt);
                                        }
                                    }
                                }

                            }
                            else {
                                var tmp = responsetext.split('|');
                                if (tmp[0] == "IMGNAME") {
                                    if (tmp.length == 3) {
                                        var stxt = _CommandExpression_GetAllPictureName + _TrackerMain_Total + ':' + tmp[1] + _TrackerMain_Current + ':' + tmp[2];
                                        tmprecord.set("process", stxt);
                                        addNewInfo(trackername, stxt);
                                    }
                                }
                                else if (tmp[0] == "IMGDATA") {
                                    if (tmp.length == 4) {
                                        var stxt = tmp[1] + _TrackerMain_Total + ':' + tmp[2] + _TrackerMain_Current + ':' + tmp[3];
                                        tmprecord.set("process", stxt);
                                        addNewInfo(trackername, stxt);

                                        if (g_PhotoWindowDictionary.ContainsKey(sssid)) {
                                            var tmpwin = g_PhotoWindowDictionary.Item(sssid);
                                            tmpwin.changeImgUploadProgress(tmp[1], tmp[2], tmp[3]);
                                        }
                                    }
                                }
                                else if (commandid == EnumMT88Command.OTA_SET_SERVER) {
                                    tmprecord.set("process", _TrackerMain_WaitingForOTA);
                                    if (g_OTAWindowObject != null) {
                                        g_OTAWindowObject.changeDisplay(sssid, _TrackerMain_WaitingForOTA);
                                    }
                                }
                                else if (commandid == EnumMT88Command.OTA_CHECK_FILE) {
                                    if (responsetext.indexOf("OTASAMEVER") == 0) {
                                        var tmp = responsetext.split('|');
                                        if (tmp == 2) {//后面带版本号
                                            if (g_OTAWindowObject != null) {
                                                g_OTAWindowObject.changeOldFirmware(sssid, tmp[1]);
                                            }
                                        }
                                        tmprecord.set("process", _Message_OTASameVer2);
                                        if (g_OTAWindowObject != null) {
                                            g_OTAWindowObject.changeDisplay(sssid, _Message_OTASameVer2);
                                        }
                                    }
                                    else if (responsetext == "OTAERRVER") {
                                        tmprecord.set("process", _Message_OTA_ErrVer);
                                        if (g_OTAWindowObject != null) {
                                            g_OTAWindowObject.changeDisplay(sssid, _Message_OTA_ErrVer);
                                        }
                                    }
                                    else if (responsetext == "OTAOK") {
                                        tmprecord.set("process", _Message_OTA_OK);
                                        if (g_OTAWindowObject != null) {
                                            g_OTAWindowObject.changeDisplay(sssid, _Message_OTA_OK);
                                        }
                                    }
                                }
                                else if (commandid == EnumMT88Command.OTA_CHECK || commandid == EnumMT88Command.OTA_AUTH || commandid == EnumMT88Command.OTA_START) {
                                    tmprecord.set("process", responsetext);
                                    var s = responsetext;
                                    if (responsetext == "OTAWRITTING")
                                        s = _Message_OTA_Writing;
                                    else if (responsetext.indexOf("OTASUCCESS") == 0) {
                                        s = _Message_OTA_Success;
                                        var tmp = responsetext.split('|');
                                        if (tmp.length == 2) {
                                            if (g_OTAWindowObject != null) {
                                                g_OTAWindowObject.changeOldFirmware(sssid, tmp[1]);
                                            }
                                        }
                                    }
                                    else if (responsetext == "OTAFAILED")
                                        s = _Message_OTA_WriteFailed;
                                    if (g_OTAWindowObject != null) {
                                        if (s == _Message_OTA_WriteFailed)
                                            g_OTAWindowObject.changeUpgradeProgress(sssid, 100, 0);
                                        else if (s == "NOT")
                                            g_OTAWindowObject.changeUpgradeProgress(sssid, 100, 0);
                                        else
                                            g_OTAWindowObject.changeUpgradeProgress(sssid, 100, 100);
                                        g_OTAWindowObject.changeDisplay(sssid, s);
                                    }
                                }
                                else if (commandid == EnumMT88Command.OTA_SEND_DATA) {
                                    var p = ((parseFloat(tmp[1]) + 1) / parseFloat(tmp[2]) * 100).toFixed(2) + "%";
                                    tmprecord.set("process", "OTA:" + p);
                                    if (g_OTAWindowObject != null) {
                                        g_OTAWindowObject.changeUpgradeProgress(sssid, parseInt(tmp[2]), parseInt(tmp[1]) + 1);
                                    }
                                }

                            }
                        }
                    }

                }
            }
        });
        if (noresponsesssidArray.length > 0) {
            searchTimer = window.setTimeout("searchResponseWithStatus()", 10000);
        }
    }
}


var paramIds = "";
var smsSendTimes = 0;
function searchSMSResponseWithStatus() {
    var newIds = "";
    for (var i = 0; i < paramIds.length; i++) {
        if (i == 0)
            newIds = paramIds[i];
        else
            newIds += "|" + paramIds[i];
    }
    if (newIds == "") return;
    searchsmsresponsewithstatusstore.baseParams = { deviceids: newIds };
    searchsmsresponsewithstatusstore.reload({
        callback: function() {
            var responsecount = searchsmsresponsewithstatusstore.getCount();
            var i;
            for (i = 0; i < responsecount; i++) {
                var record = searchsmsresponsewithstatusstore.getAt(i);
                var sssid = record.get("sssid");
                var status = record.get("status");
                var commandid = record.get("commandid");
                var responsetext = record.get("responsetext");
                var trackername = record.get("trackername");
                var devicecount = devicestore.getCount();
                var j;
                for (j = 0; j < devicecount; j++) {
                    var tmprecord = devicestore.getAt(j);
                    var tmpsssid = tmprecord.get("sssid");
                    var tmpprocess = tmprecord.get("process");
                    if (tmpsssid == sssid) {//&& tmpprocess == _TrackerMain_Sending) {
                        if (status != 1) {
                            if (status == -1) {
                                paramIds.remove(tmpsssid);
                                tmprecord.set("process", _SMSResource_SendFailed);
                            }
                            else if (status == 0) {
                                paramIds.remove(tmpsssid);
                                tmprecord.set("process", _TrackerMain_TimeOut);
                            }
                            else if (status == 2) {
                                tmprecord.set("process", _SMSResource_CommandSucceed);
                            }
                            else if (status == -3) {
                                tmprecord.set("process", "消息有误");
                            }
                            else if (status == -4) {
                                tmprecord.set("process", "不支持");
                            }
                        }
                        else {
                            paramIds.remove(tmpsssid);
                            var isnewprotocol = isNaN(commandid);
                            if (!isnewprotocol) {
                                var cmdid = parseInt(commandid, 16);

                                if (cmdid == EnumGPRSCommand.Read_Interval) {
                                    tmprecord.set("process", responsetext);
                                    addNewInfo(trackername, responsetext);
                                }
                                else if (cmdid == EnumGPRSCommand.Read_Authorization) {
                                    tmprecord.set("process", responsetext);
                                    addNewInfo(trackername, responsetext);
                                }
                                else if (cmdid == EnumGPRSCommand.Get_SN_IMEI) {
                                    tmprecord.set("process", responsetext);
                                    addNewInfo(trackername, responsetext);
                                }

                                else {
                                    var stxt = getCommandStringFromCommandID(cmdid) + " " + _TrackerMain_Received;
                                    tmprecord.set("process", stxt);
                                    addNewInfo(trackername, stxt);
                                }
                            }
                            else {
                                if (responsetext == "PICOK") {
                                    tmprecord.set("process", _TrackerMain_GetPictureOK);
                                }
                                else if (commandid == EnumMT88Command.Read_Firmware_version_and_SN) {
                                    tmprecord.set("process", responsetext);
                                    addNewInfo(trackername, responsetext);
                                    
                                }
                                else if (commandid == EnumMT88Command.Get_Event_Flag_for_GPRS) {
                                    var gprsAuth = new GPRSAuthWindow(sssid, trackername, responsetext, false);
                                    var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received + ':' + responsetext;
                                    tmprecord.set("process", stxt);
                                    addNewInfo(trackername, stxt);
                                }
                                else if (commandid == EnumMT88Command.Get_Event_Flag_for_Taking_Picture) {
                                    var photoAuth = new GPRSAuthWindow(sssid, trackername, responsetext, true);
                                    var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received + ':' + responsetext;
                                    tmprecord.set("process", stxt);
                                    addNewInfo(trackername, stxt);
                                }
                                else if (commandid == EnumMT88Command.Get_Authorize_phone_number_and_SMS_Event_Flag) {
                                    var smsauth = new SMSAuthWindow();
                                    smsauth.beginSetAuth(sssid, trackername, responsetext);
                                    var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received + ':' + responsetext;
                                    tmprecord.set("process", stxt);
                                    addNewInfo(trackername, stxt);
                                }
                                else if (commandid == EnumMT88Command.Get_Image_Names) {

                                    if (g_PhotoWindowDictionary.ContainsKey(sssid)) {
                                        var tmpwin = g_PhotoWindowDictionary.Item(sssid);
                                        tmpwin.hide();
                                    }
                                    var photolist = new PhotoListWindow(sssid, trackername, responsetext);
                                    g_PhotoWindowDictionary.Add(sssid, photolist);
                                    var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                    tmprecord.set("process", stxt);
                                    addNewInfo(trackername, stxt);
                                }
                                else if (commandid == EnumMT88Command.Get_Image_Data) {
                                    var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                    tmprecord.set("process", stxt);
                                    addNewInfo(trackername, stxt);
                                    if (g_PhotoWindowDictionary.ContainsKey(sssid)) {
                                        var tmpwin = g_PhotoWindowDictionary.Item(sssid);
                                        tmpwin.completeUploadImg();
                                    }
                                    new Ext.Window({
                                        title: trackername + " " + responsetext,
                                        autoScroll: true,
                                        width: 660,
                                        height: 520,
                                        constrain:true,
                                        plain: true,
                                        html: "<img src='HandlerGetPictureByFileName?trackername=" + escape(trackername) + "&filename=" + responsetext + "'></img>"

                                    }).show();
                                }
                                else if (commandid == EnumMT88Command.Delete_Pictures) {

                                    var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                    //addOneTCPCommand(sssid, EnumGPRSCommand.NotSupportThisCommand, '', EnumMT88Command.Get_Image_Names, '0');
                                    tmprecord.set("process", stxt);
                                    addNewInfo(trackername, stxt);
                                    Ext.Ajax.request({
                                        url: 'HandlerGetImageNameList',
                                        method: 'post',
                                        params: {
                                            sssid: sssid,
                                            trackername: trackername
                                        },
                                        success: function(r) {
                                            var responsetext = r.responseText;
                                            var p = responsetext.split(':');
                                            if (p.length == 3) {

                                                if (g_PhotoWindowDictionary.ContainsKey(p[0])) {
                                                    var tmpwin = g_PhotoWindowDictionary.Item(p[0]);
                                                    tmpwin.close();
                                                }
                                                var photolist = new PhotoListWindow(p[0], p[1], p[2]);
                                                g_PhotoWindowDictionary.Add(p[0], photolist);
                                            }
                                        }
                                    });
                                }
                                else if (commandid == EnumMT88Command.Read_Authed_RFID) {
                                    if (g_RFIDWindowDictionary.ContainsKey(sssid)) {
                                        var tmpwin = g_RFIDWindowDictionary.Item(sssid);
                                        tmpwin.close();
                                    }
                                    var rfidlistwin = new RFIDAuthWindow(sssid, trackername, responsetext, true, null);
                                    g_RFIDWindowDictionary.Add(sssid, rfidlistwin);
                                    var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                    tmprecord.set("process", stxt);
                                    addNewInfo(trackername, stxt);
                                }
                                else if (commandid == EnumMT88Command.Read_Auth_NO) {
                                    var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received + ':' + responsetext;
                                    tmprecord.set("process", stxt);
                                    addNewInfo(trackername, stxt);
                                }
                                else if (commandid == EnumMT88Command.Check_RFID_Auth) {
                                    if (responsetext == "0") {
                                        tmprecord.set("process", _TrackerMain_Unauthorized);
                                    }
                                    else {
                                        tmprecord.set("process", _TrackerMain_Authorized);
                                    }
                                }
                                
                                else {
                                    var stxt = getCommandStringFromCommandID(commandid) + " " + _TrackerMain_Received;
                                    tmprecord.set("process", stxt);
                                    addNewInfo(trackername, stxt);
                                }
                            }
                        }
                    }
                }
            }
        }
    });

    if (paramIds.length > 0) {
        if (smsSendTimes <= 60) {
            smsSendTimes++;
            window.setTimeout("searchSMSResponseWithStatus()", 20000);
        }
        else {
            smsSendTimes = 0;
            for (var i = 0; i < paramIds.length; i++) {
                var count = devicestore.getCount();
                for (i = 0; i < count; i++) {
                    var record = devicestore.getAt(i);
                    var sssid = record.get("sssid");
                    var j;
                    for (j = 0; j < paramIds.length; j++) {
                        if (paramIds[j] == sssid) {
                            record.set("process", _TrackerMain_TimeOut);
                            record.set("actionretry", "icon-resend");
                            record.set("qtipretry", _TrackerMain_Retry);
                        }
                    }
                }
            }
        }
    }
}


function createGeoFenceMapWindow(txttitle, toolbar) {
        var tmpwin;
        if (meimaptype == 0) {
            if (toolbar) {
                tmpwin = new Ext.ux.GMapWindow({
                    title: txttitle,
                    closable: true,
                    width: 500,
                    height: 450,
                    minimizable: true,
                    maximizable: true,
                    plain: true,
                    x: nextwindowx, //defined in paneldevicelist.js
                    y: nextwindowy,
                    tbar: toolbar,
                    listeners: {
                        'minimize': function() {
                            addTaskButtonForWindow(tmpwin);
                        }
                    }


                });
            }
            else {
                tmpwin = new Ext.ux.GMapWindow({
                    title: txttitle,
                    closable: true,
                    width: 500,
                    height: 450,
                    minimizable: true,
                    maximizable: true,
                    plain: true,
                    x: nextwindowx, //defined in paneldevicelist.js
                    y: nextwindowy,
                    listeners: {
                        'minimize': function() {
                            addTaskButtonForWindow(tmpwin);
                        }
                    }
                });
            }
        }
        else if (meimaptype == 1) {
            if (toolbar) {
                tmpwin = new Ext.ux.BMapWindow({
                    title: txttitle,
                    closable: true,
                    width: 500,
                    height: 450,
                    minimizable: true,
                    maximizable: true,
                    plain: true,
                    x: nextwindowx,
                    y: nextwindowy,
                    tbar: toolbar,
                    listeners: {
                        'minimize': function() {
                            addTaskButtonForWindow(tmpwin);
                        }
                    }
                });
            }
            else {
                tmpwin = new Ext.ux.BMapWindow({
                    title: txttitle,
                    closable: true,
                    width: 500,
                    height: 450,
                    minimizable: true,
                    maximizable: true,
                    plain: true,
                    x: nextwindowx,
                    y: nextwindowy,
                    listeners: {
                        'minimize': function() {
                            addTaskButtonForWindow(tmpwin);
                        }
                    }
                });
            }
        }
        else if (meimaptype == 2) {
            if (toolbar) {
                tmpwin = new Ext.ux.MMapWindow({
                    title: txttitle,
                    closable: true,
                    width: 500,
                    height: 450,
                    minimizable: false,
                    maximizable: true,
                    plain: true,
                    x: nextwindowx,
                    y: nextwindowy,
                    tbar: toolbar
                });
            }
            else {
                tmpwin = new Ext.ux.MMapWindow({
                    title: txttitle,
                    closable: true,
                    width: 500,
                    height: 450,
                    minimizable: false,
                    maximizable: true,
                    plain: true,
                    x: nextwindowx,
                    y: nextwindowy
                });
            }
        }
        else if(meimaptype == 3){
            if (toolbar) {
                tmpwin = new Ext.ux.GMapWindowV3({
                    title: txttitle,
                    closable: true,
                    width: 500,
                    height: 450,
                    minimizable: true,
                    maximizable: true,
                    plain: true,
                    x: nextwindowx, //defined in paneldevicelist.js
                    y: nextwindowy,
                    tbar: toolbar,
                    listeners: {
                        'minimize': function() {
                            addTaskButtonForWindow(tmpwin);
                        }
                    }


                });
            }
            else {
                tmpwin = new Ext.ux.GMapWindowV3({
                    title: txttitle,
                    closable: true,
                    width: 500,
                    height: 450,
                    minimizable: true,
                    maximizable: true,
                    plain: true,
                    x: nextwindowx, //defined in paneldevicelist.js
                    y: nextwindowy,
                    listeners: {
                        'minimize': function() {
                            addTaskButtonForWindow(tmpwin);
                        }
                    }
                });
            }
        }
        else if(meimaptype == 4){
            if (toolbar) {
                tmpwin = new Ext.ux.QMapWindow({
                    title: txttitle,
                    closable: true,
                    width: 500,
                    height: 450,
                    minimizable: true,
                    maximizable: true,
                    plain: true,
                    x: nextwindowx, //defined in paneldevicelist.js
                    y: nextwindowy,
                    tbar: toolbar,
                    listeners: {
                        'minimize': function() {
                            addTaskButtonForWindow(tmpwin);
                        }
                    }


                });
            }
            else {
                tmpwin = new Ext.ux.QMapWindow({
                    title: txttitle,
                    closable: true,
                    width: 500,
                    height: 450,
                    minimizable: true,
                    maximizable: true,
                    plain: true,
                    x: nextwindowx, //defined in paneldevicelist.js
                    y: nextwindowy,
                    listeners: {
                        'minimize': function() {
                            addTaskButtonForWindow(tmpwin);
                        }
                    }
                });
            }
        }
        return tmpwin;
    }

var searchresponsereader = new Ext.data.JsonReader({}, [
   { name: 'sssid' },
   { name: 'commandid' },
   { name: 'responsetext' },
   { name: 'received', type: 'boolean' },
   { name: 'timeout', type: 'boolean' },
   { name: 'trackername' }
]);

var searchresponseproxy = new Ext.data.HttpProxy({
    method: 'post',
    url: 'HandlerSearchResponse'
});

var searchresponsestore = new Ext.data.Store({
    autoSave: true,
    reader: searchresponsereader,
    proxy: searchresponseproxy,
    sortInfo: { field: 'sssid', direction: "ASC" }
});

function timerToSeconds(timerstring){
    var tmp = timerstring.split(':');
    return parseInt(tmp[0],10) * 60+ parseInt(tmp[1],10);
}

function sendCommand() {
    if (cmbcommand.getValue()) {
        var cmdtext = cmbcommand.getRawValue();
        var cmd = EnumGPRSCommand.NotSupportThisCommand;
        var param = "";
        var mt88cmd = "";
        var mt88param = "";
        var gbcommand = null;
        var gbparamdata = [];
        var smscmd = "", smsparam = "", mt88smscmd = "", mt88smsparam = "";
        if (cmdtext == _CommandExpression_OTAUpgrade) {
            Ext.MessageBox.buttonText.ok = _TrackerMain_Yes;
            Ext.MessageBox.buttonText.cancel = _TrackerMain_No;
            Ext.MessageBox.confirm("", _Message_SurttoOTA, function(btn, text) {
                if (btn == 'yes') {
                    mt88cmd = EnumMT88Command.OTA_CHECK;
                    addTCPOrSMSCommand('HandlerSendCommand', cmd, param, mt88cmd, mt88param);
                }
            });
        }
        
        else {
            if (cmdtext == _CommandExpression_TrackOnDemand) {
                cmd = EnumGPRSCommand.Track_on_Demand;
                param = "";
                mt88smscmd = EnumMT88Command.Track_on_Demand_Google_Link_only_for_SMS;
                mt88cmd = EnumMT88Command.Track_on_Demand_only_for_GPRS;
                mt88smsparam = mt88param = "";
            }
            else if (cmdtext == _CommandExpression_TrackByPresetInterval) {
                smscmd = EnumGTVTSMSCommand.Track_by_Preset_Interval;
                smsparam = padLeft(txtparams1.getValue().toString(), '0', 3);
            }
            else if (cmdtext == _CommandExpression_TrackBySMS) {
                smscmd = EnumGTVTSMSCommand.Track_By_SMS;
                mt88smscmd = EnumMT88Command.Track_on_Demand_only_for_SMS;
                mt88smsparam = "";
            }
            else if (cmdtext == _CommandExpression_SetSMSIntervalCounter) {
                mt88smscmd = EnumMT88Command.Track_on_interval_and_counter_only_for_SMS;
                mt88smsparam = txtparams1.getValue() + "," + txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_SetGPRSInterval) {
                smscmd = EnumGTVTSMSCommand.Set_GPRS_Interval;
                cmd = EnumGPRSCommand.Track_by_Interval;
                param = txtparams1.getValue();
                smsparam = padLeft(txtparams1.getValue().toString(), '0', 5);
            }
            else if (cmdtext == _CommandExpression_Authorization) {
                cmd = EnumGPRSCommand.Authorization;
                smscmd = EnumGTVTSMSCommand.Authorization;
                param = cmbparams1.getValue().toString() + "|" + txtparams2.getValue() + "|" + txtparams3.getValue();
                smsparam = (cmbparams1.getValue() + 1).toString() + "," + txtparams2.getValue() + "," + txtparams3.getValue();
            }
            else if (cmdtext == _CommandExpression_SetOverSpeed) {
                if (commandmodel == 0) {
                    cmd = EnumGPRSCommand.Overspeed;
                    param = cmbparams1.getValue().toString();
                    smscmd = EnumGTVTSMSCommand.OverSpeed;
                    smsparam = padLeft(cmbparams1.getValue().toString(), '0', 2);
                }
                else {
                    mt88smscmd = mt88cmd = EnumMT88Command.Set_Speeding;
                    var tmp = txtparams1.getValue();
                    if (showmiles)
                        tmp = parseInt(miles2kilos(tmp));
                    mt88smsparam = mt88param = tmp;
                }
            }
            else if (cmdtext == _CommandExpression_SetAPN) {
                smscmd = EnumGTVTSMSCommand.Set_APN;
                smsparam = txtparams1.getValue() + "," + txtparams2.getValue() + "," + txtparams3.getValue();
            }
            else if (cmdtext == _CommandExpression_SetIPPort) {
                smscmd = EnumGTVTSMSCommand.Set_IP_Port;
                smsparam = txtparams1.getValue() + "," + cmbparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_SetSMSInitials) {
                smscmd = EnumGTVTSMSCommand.Set_SMS_Initials;
                smsparam = (cmbparams1.getValue() + 1).toString() + "," + txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_SetMovementAlarm) {
                cmd = EnumGPRSCommand.Movement_Alarm;
                smscmd = EnumGTVTSMSCommand.MovementAlarm;
                param = cmbparams1.getValue().toString();
                smsparam = padLeft(param, '0', 2);
            }
            else if (cmdtext == _CommandExpression_EnableGPRSTracking) {
                smscmd = EnumGTVTSMSCommand.Set_GPRS_Tracking;
                smsparam = cmbparams1.getValue().toString();
            }
            else if (cmdtext == _CommandExpression_SetGeoFence) {
                //not write yet
                if (commandmodel == 0) {
                    if (chkgeoturnoff.checked) {
                        cmd = EnumGPRSCommand.GeoFence_In_Alarm;
                        smscmd = EnumGTVTSMSCommand.GeoFence_In_Alarm;
                        smsparam = param = "";
                    }
                    else {
                        if (radgeoinalarm.checked) {
                            cmd = EnumGPRSCommand.GeoFence_In_Alarm;
                            smscmd = EnumGTVTSMSCommand.GenFence_In_Alarm;
                        }
                        else {
                            cmd = EnumGPRSCommand.GeoFence_Out_Alarm;
                            smscmd = EnumGTVTSMSCommand.GeoFence_Out_Alarm;
                        }
                        param = txtLowerLeftX.getValue() + "," + cmbEWLowerLeft.getValue() + "," + txtLowerLeftY.getValue() + "," + cmbNSLowerLeft.getValue();
                        param += "," + txtUpperRightX.getValue() + "," + cmbEWUpperRight.getValue() + "," + txtUpperRightY.getValue() + "," + cmbNSUpperRight.getValue();
                        smsparam = param;
                    }
                }
                else {
                    mt88smscmd = mt88cmd = EnumMT88Command.Set_Geo_fence_alert;
                    var lati = txtCircleGeoFenceLati.getValue().toFixed(6);
                    var longi = txtCircleGeofenceLongi.getValue().toFixed(6);
                    var inalarm = chkCircleGFenceInAlarm.checked ? "1" : "0";
                    var outalarm = chkCircleGFenceOutAlarm.checked ? "1" : "0";
                    mt88smsparam = mt88param = cmbCircleGFenceIndex.getValue() + "," + lati + "," + longi + "," + txtCircleRadius.getValue() + "," + inalarm + "," + outalarm;
                }
            }
            else if (cmdtext == _CommandExpression_GetIMEI) {
                smscmd = EnumGTVTSMSCommand.Get_IMEI;
            }
            else if (cmdtext == _CommandExpression_SetGeoFenceCircle) {
                cmd = EnumGPRSCommand.GeoFence_Circle;
                smscmd = EnumGTVTSMSCommand.GeoFenceCircle;
                var strlati = txtCircleGeoFenceLati.getValue().toString();
                var strlongi = txtCircleGeofenceLongi.getValue().toString();

                if (strlati != "" && strlongi != "") {
                    var lati = parseFloat(strlati).toFixed(6);
                    var longi = parseFloat(strlongi).toFixed(6);

                    var inalarm = chkCircleGFenceInAlarm.checked ? "1" : "0";
                    var outalarm = chkCircleGFenceOutAlarm.checked ? "1" : "0";
                    if (inalarm == "0" && outalarm == "0")
                        param = "";
                    else
                        param = lati + "," + longi + "," + txtCircleRadius.getValue() + "," + inalarm + "," + outalarm;
                }
                else
                    param = "";
                smsparam = param;
            }
            else if (cmdtext == _CommandExpression_SetExtendedFunctions) {
                if (commandmodel == 0) {
                    cmd = EnumGPRSCommand.Extended_Settings;
                    smscmd = EnumGTVTSMSCommand.Extended_Functions;
                    mt88smscmd = mt88cmd = "";
                    smsparam = param = mt88param = cmbparams1.getValue() + cmbparams2.getValue() + cmbparams3.getValue() + cmbparams4.getValue() + "1" + cmbparams5.getValue() + cmbparams6.getValue() +"0" + cmbparams7.getValue()+cmbparams8.getValue();
                }
                else {
                    mt88smscmd = mt88cmd = EnumMT88Command.Set_extended_functions;
                    mt88param= mt88smsparam = cmbparams1.getValue()+"1";
                }
            }
            else if (cmdtext == _CommandExpression_Enginelimited) {
                if (cmbparams1.getValue() == 0) {
                    cmd = EnumGPRSCommand.Output_Control_Limited_Below10kmh_VTOnly;
                    smscmd = EnumGTVTSMSCommand.Output_limit_Below10kmh;
                }
                else {
                    cmd = EnumGPRSCommand.Output_Control_Limited_Below20kmh_VTOnly;
                    smscmd = EnumGTVTSMSCommand.Output_limit_Below20kmh;
                }
                param = cmbparams2.getValue() + "|" + cmbparams3.getValue() + "|" + cmbparams4.getValue() + "|" + cmbparams5.getValue() + "|" + cmbparams6.getValue();
                smsparam = cmbparams2.getValue() + "," + cmbparams3.getValue() + "," + cmbparams4.getValue() + "," + cmbparams5.getValue() + "," + cmbparams6.getValue();
            }
            else if (cmdtext == _CommandExpression_EngineUnlimited) {
                if (showSMS) {
                    if (gprsorsmsgroup.getValue().inputValue == 0) {
                        cmd = EnumGPRSCommand.Output_Control_Unlimited_VTOnly;
                        param = cmbparams2.getValue() + "|" + cmbparams3.getValue() + "|" + cmbparams4.getValue() + "|" + cmbparams5.getValue() + "|" + cmbparams6.getValue();
                    }
                    else {
                        smscmd = EnumGTVTSMSCommand.Output_Unlimit;
                        smsparam = cmbparams2.getValue() + "," + cmbparams3.getValue();
                    }
                }
                else {
                    cmd = EnumGPRSCommand.Output_Control_Unlimited_VTOnly;
                    param = cmbparams2.getValue() + "|" + cmbparams3.getValue() + "|" + cmbparams4.getValue() + "|" + cmbparams5.getValue() + "|" + cmbparams6.getValue();
                }
            }
            else if (cmdtext == _CommandExpression_TriggeredAlarms) {
                cmd = EnumGPRSCommand.Triggered_Alarms;
                param = cmbparams1.getValue() + cmbparams2.getValue() + cmbparams3.getValue() + cmbparams4.getValue() + cmbparams5.getValue();
            }
            else if (cmdtext == _CommandExpression_SetSleepMode) {
                cmd = EnumGPRSCommand.Sleep_Mode;
                smscmd = EnumGTVTSMSCommand.Sleep_Mode;
                smsparam = param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_SetPowerDown) {
                cmd = EnumGPRSCommand.Power_Down;
                param = padLeft(txtparams1.getValue().toString(), '0', 2);
            }
            else if (cmdtext == _CommandExpression_SetWiretapping) {

                cmd = EnumGPRSCommand.Listen;
                smscmd = EnumGTVTSMSCommand.Listen;
                smsparam = param = txtparams1.getValue();
                mt88smscmd = mt88cmd = EnumMT88Command.Set_Listening_NO;
                if (txtparams2 != null)
                    mt88smsparam = mt88param = txtparams1.getValue() + "," + txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_SetTimeZone) {
                if (txtparams1.isValid()) {
                    cmd = EnumGPRSCommand.Time_Zone;
                    smscmd = EnumGTVTSMSCommand.Change_TimeZone;
                    smsparam = param = txtparams1.getValue();
                }
            }
            else if (cmdtext == _CommandExpression_ClearKilometers) {
                cmd = EnumGPRSCommand.Clear_Distance;
                //smscmd = EnumGTVTSMSCommand
            }
            else if (cmdtext == _CommandExpression_GPRS_SetVeerReport) {
                if (txtparams1.isValid()) {
                    cmd = EnumGPRSCommand.Veer_Report;
                    param = txtparams1.getValue();
                    mt88smscmd = mt88cmd = EnumMT88Command.Track_on_course_change_only_for_GPRS;
                    mt88smsparam = mt88param = txtparams1.getValue();
                }
            }
            else if (cmdtext == _CommandExpression_RebootGPS) {
                cmd = EnumGPRSCommand.Reboot_GPS;
                smscmd = EnumGTVTSMSCommand.Reboot_GPS;
                param = "";
                mt88smscmd = mt88cmd = EnumMT88Command.Reboot_GPS_module;

            }
            else if (cmdtext == _CommandExpression_SetGPSAntennaAlarm) {
                cmd = EnumGPRSCommand.GPS_Antenna_Cut;
                param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_GPRS_SetHeartBeat) {
                cmd = EnumGPRSCommand.Heartbeat;
                param = txtparams1.getValue();
                mt88smscmd = mt88cmd = EnumMT88Command.Set_heart_beat_time_only_for_GPRS;
                mt88smsparam = mt88param = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_GPRS_SetLogInterval) {
                cmd = EnumGPRSCommand.Log_by_Interval;
                smscmd = EnumGTVTSMSCommand.Log_By_Interval;
                smsparam = param = txtparams1.getValue();
                mt88smscmd = mt88cmd = EnumMT88Command.Set_interval_for_logging;
                mt88smsparam = mt88param = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_GPRS_FormatLoggedData) {
                cmd = EnumGPRSCommand.Format;

                param = "";
            }
            else if (cmdtext == _CommandExpression_GPRS_ReadLoggedData) {
                cmd = EnumGPRSCommand.Read_Logged_Data;
                param = "";
            }
            else if (cmdtext == _CommandExpression_GPRS_ReadInterval) {
                cmd = EnumGPRSCommand.Read_Interval;
                param = "";
            }
            else if (cmdtext == _CommandExpression_ReadAuthorization) {
                cmd = EnumGPRSCommand.Read_Authorization;

                param = cmbparams1.getValue().toString();
            }
            else if (cmdtext == _CommandExpression_ReasSNIMEIFirmware) {
                cmd = EnumGPRSCommand.Get_SN_IMEI;
                smscmd = EnumGTVTSMSCommand.Get_IMEI;
                param = "";
            }
            else if (cmdtext == _CommandExpression_Initialization) {
                cmd = EnumGPRSCommand.Initialization;
                smscmd = EnumGTVTSMSCommand.Initialization;
                param = "";
                mt88smscmd = mt88cmd = EnumMT88Command.Initialize_parameters_except_for_password;
                mt88smsparam = mt88param = "";
            }
            else if (cmdtext == _CommandExpression_SetSMSCommnadHeader) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_SMS_Header_for_Event;
                mt88smsparam = mt88param = cmbparams1.getValue().toString() + "," + txtparams2.getValue()
            }
            else if (cmdtext == _CommandExpression_SetIntervalCounter) {
                mt88smscmd = mt88cmd = EnumMT88Command.Track_on_interval_and_counter_only_for_GPRS;
                mt88smsparam = mt88param = txtparams1.getValue() + ",0"; //+ txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_SetDistanceInverval) {
                cmd = EnumGPRSCommand.Distance_Interval;
                param = txtparams1.getValue();
                mt88cmd = EnumMT88Command.Track_on_distance_interval;
                mt88param = txtparams1.getValue();
                mt88smscmd = mt88cmd;
                mt88smsparam = mt88param;
            }
            else if (cmdtext == _CommandExpression_SetGPRS) {
                cmd = EnumGPRSCommand.ChangeIPPortAPN;
                smscmd = EnumGTVTSMSCommand.Set_IP_Port;
                smsparam = param = cmbparams1.getValue() + "," + txtparams2.getValue() + "," + txtparams3.getValue() + "," + txtparams4.getValue() + "," + txtparams5.getValue() + "," + txtparams6.getValue();
                mt88smscmd = mt88cmd = EnumMT88Command.Set_GPRS;
                mt88smsparam = mt88param = cmbparams1.getValue() + "," + txtparams2.getValue() + "," + txtparams3.getValue() + "," + txtparams4.getValue() + "," + txtparams5.getValue() + "," + txtparams6.getValue();
            }
            else if (cmdtext == _CommandExpression_SetSecondGPRS) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_Second_GPRS_Server;
                mt88smsparam = mt88param = txtparams1.getValue() + "," + txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_GetDetailLocation) {
                mt88smscmd = EnumMT88Command.Track_on_Demand_for_Street_SMS;
                mt88smsparam = "";
            }
            else if (cmdtext == _CommandExpression_DeleteEventGetNewEvent) {
                mt88cmd = EnumMT88Command.Delete_event_and_Get_new_Event_in_memory;
                mt88param = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_GetAuthorizePhoneAndFlag) {
                mt88smscmd = mt88cmd = EnumMT88Command.Get_Authorize_phone_number_and_SMS_Event_Flag;
                mt88smsparam = mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_SetAuthorizePhoneAndFlag) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_Authorize_phone_number_and_SMS_Event_Flag;
                mt88smsparam = mt88param = cmbparams1.getValue() + "," + txtparams2.getValue() + "," + cmbparams3.getValue();
            }
            else if (cmdtext == _CommandExpression_SetSMSEventFlag) {
                mt88smscmd = mt88cmd = EnumMT88Command.Add_SMS_Event_Flag;
                mt88smsparam = mt88param = cmbparams1.getValue() + "," + cmbparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_DeleteSMSEventFlag) {
                mt88smscmd = mt88cmd = EnumMT88Command.Delete_SMS_Event_Flag;
                mt88smsparam = mt88param = cmbparams1.getValue() + "," + cmbparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_DeleteGeoFence) {
                mt88smscmd = mt88cmd = EnumMT88Command.Delete_Geo_fence_alert;
                mt88smsparam = mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_SetGPSSleepMode) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_GPS_sleep_mode;
                mt88smsparam = mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_SetSleepTime) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_go_into_sleep_time;
                mt88smsparam = mt88param = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_SetSMSTimeZone) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_SMS_time_zone;
                mt88smsparam = mt88param = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_SetGPRSTimeZone) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_GPRS_time_zone;
                mt88smsparam = mt88param = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_SetEventFlagforGPRS) {
                if (gprssetauthwindow != null) {
                    mt88smscmd = mt88cmd = EnumMT88Command.Set_Event_Flag_for_GPRS;
                    mt88smsparam = mt88param = gprssetauthwindow.getAuth();
                }
                else {
                    showGPRSAuthWindow();
                }
            }
            else if (cmdtext == _CommandExpression_GetEventFlagforGPRS) {
                mt88smscmd = mt88cmd = EnumMT88Command.Get_Event_Flag_for_GPRS;
            }
            else if (cmdtext == _CommandExpression_Outputcontrol) {
                mt88cmd = EnumMT88Command.Output_control;
                var tmp = txtparams1.getValue();
                if (showmiles)
                    tmp = parseInt(miles2kilos(tmp));
                mt88smsparam = mt88param = tmp.toString() + "," + cmbparams2.getValue() + cmbparams3.getValue() + cmbparams4.getValue() + cmbparams5.getValue() + cmbparams6.getValue();
            }
            else if (cmdtext == _CommandExpression_SendSMSFromGPRS) {
                mt88smscmd = mt88cmd = EnumMT88Command.Send_SMS_From_GPRS;
                var body = txtparams2.getValue();
                var codetype = "0";
                if (isUnicode(body)) {
                    codetype = "1";
                    body = toUnicode(body);
                }

                mt88smsparam = mt88param = codetype + "," + txtparams1.getValue() + "," + body;
            }
            else if (cmdtext == _CommandExpression_ProtocolControl) {
                mt88smscmd = mt88cmd = EnumMT88Command.Protocol_control;
                mt88smsparam = mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_ReadEEPData) {
                mt88smscmd = mt88cmd = EnumMT88Command.Read_EEP_Data;
                mt88smsparam = mt88param = txtparams1.getValue() + "," + txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_ReadFirmwareandSN) {
                mt88smscmd = mt88cmd = EnumMT88Command.Read_Firmware_version_and_SN;
            }
            else if (cmdtext == _CommandExpression_RebootGSM) {
                mt88smscmd = mt88cmd = EnumMT88Command.Reboot_GSM_module;
                smscmd = EnumGTVTSMSCommand.Reboot_GSM;
            }
            else if (cmdtext == _CommandExpression_SetTowAlert) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_tow_alert;
                mt88smsparam = mt88param = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_GetLastPicture) {
                mt88smscmd = mt88cmd = EnumMT88Command.Get_Lastest_Picture;

            }
            else if (cmdtext == _CommandExpression_SetDNSServerIP) {
                mt88smscmd = mt88smscmd = mt88cmd = EnumMT88Command.Set_DNS_Server_IP;
                mt88smsparam = mt88smsparam = mt88param = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_ChangePassword) {
                smscmd = EnumGTVTSMSCommand.Change_Password;
                mt88smscmd = mt88cmd = EnumMT88Command.Change_Password;
                if (txtparams1.getValue() == txtparams2.getValue()) {
                    mt88smsparam = mt88param = txtparams1.getValue();
                    smsparam = txtparams1.getValue();
                }
                else {
                    msgRetypePasswordNotSame();
                    return;
                }

            }
            else if (cmdtext == _CommandExpression_GetAllPictureName) {
                mt88smscmd = mt88cmd = EnumMT88Command.Get_Image_Names;
                mt88smsparam = mt88param = "0";
            }
            else if (cmdtext == _CommandExpression_DelAllPicture) {
                mt88smscmd = mt88cmd = EnumMT88Command.Delete_Pictures + ",";
            }
            else if (cmdtext == _CommandExpression_GetPhotoEventFlag) {
                mt88smscmd = mt88cmd = EnumMT88Command.Get_Event_Flag_for_Taking_Picture;
            }
            else if (cmdtext == _CommandExpression_SetPhotoEventFlag) {
                if (photosetauthwindow != null) {
                    mt88smscmd = mt88cmd = EnumMT88Command.Set_Event_Flag_for_Taking_Picture;
                    mt88smsparam = mt88param = photosetauthwindow.getAuth();
                }
                else {
                    showPhotoAuthWindow();
                }
            }
            else if (cmdtext == _CommandExpression_TakePhoto) {
                mt88smscmd = mt88cmd = EnumMT88Command.Take_Picture;
                mt88smsparam = mt88param = cmbparams1.getValue(); //+ ",12345.jpg";
            }
            else if (cmdtext == _CommandExpression_RemoveBuffer) {
                mt88smscmd = mt88cmd = EnumMT88Command.Remove_Buffer;
                mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_GPSOpenClose) {
                mt88smscmd = mt88cmd = EnumMT88Command.GPS_Open_Close;
                mt88param = cmbparams1.getValue();
            }
            //            else if (cmdtext == _CommandExpression_GPRS_Message) {
            //                mt88smscmd = mt88cmd = EnumMT88Command.GPRS_Message;
            //                mt88smsparam = mt88param = cmbparams2.getValue() + "," + txtparams1.getValue() + ",E," + txtparams3.getValue();
            //            }
            else if (cmdtext == _CommandExpression_GPRS_Control_Message) {
                mt88cmd = EnumMT88Command.GRPS_Recieved_Message;
                var body = txtparams1.getValue();
                var codetype = "E";
                if (isUnicode(body)) {
                    codetype = "U";
                    body = toUnicode(body);
                }
                var flag = (Math.random() * 100000).toFixed(0).toString();
                mt88param = "1," + flag + "," + codetype + "," + body;

            }
            else if (cmdtext == _CommandExpression_GPRS_Message) {
                mt88cmd = EnumMT88Command.GRPS_Send_Message;

                var body = txtparams2.getValue();
                var codetype = "E";
                if (isUnicode(body)) {
                    codetype = "U";
                    body = toUnicode(body);
                }
                mt88param = cmbparams1.getValue() + "," + codetype + "," + body;
            }
            else if (cmdtext == _CommandExpression_ReadAuthNO) {
                mt88smscmd = mt88cmd = EnumMT88Command.Read_Auth_NO;

            }
            else if (cmdtext == _CommandExpression_SetGroupFunctionNO) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_Group_Functions_NO;
                mt88smsparam = mt88param = txtparams1.getValue() + "," + txtparams2.getValue() + "," + txtparams3.getValue();
            }
            else if (cmdtext == _CommandExpression_SetSmartSleepMode) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_Smart_Sleep_Mode;
                mt88smsparam = mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_AuthRFID) {

            }
            else if (cmdtext == _CommandExpression_BatchAuthRFID) {
                mt88smscmd = mt88cmd = EnumMT88Command.Batch_Auth_RFID;
                mt88smsparam = mt88param = txtparams1.getValue() + "," + txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_BatchDelRFID) {
                mt88smscmd = mt88cmd = EnumMT88Command.Batch_Dele_Authed_RFID;
                mt88smsparam = mt88param = txtparams1.getValue() + "," + txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_CheckRFIDAuth) {
                mt88smscmd = mt88cmd = EnumMT88Command.Check_RFID_Auth;
                mt88smsparam = mt88param = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_CheckRFIDDBSync) {
                mt88smscmd = mt88cmd = EnumMT88Command.Check_RFID_Asyn;
            }
            else if (cmdtext == _CommandExpression_DelAuthedRFID) {

            }
            else if (cmdtext == _CommandExpression_ReadAuthedRFID) {
                mt88smscmd = mt88cmd = EnumMT88Command.Read_Authed_RFID;
                mt88smsparam = mt88param = "0";
            }
            else if (cmdtext == _CommandExpression_Set_BaseMileage) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_BaseMileage;
                mt88smsparam = mt88param = (txtparams1.getValue() * 1000);
            }
            else if (cmdtext == _CommandExpression_ClearKilometersRuntime) {
                mt88smscmd = mt88cmd = EnumMT88Command.Clear_Record;
                mt88smsparam = mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_SetKilometersRuntime) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_Record;
                mt88smsparam = mt88param = txtparams1.getValue() + "," + txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_ReadGeoFence) {
                mt88cmd = EnumMT88Command.Read_EEP_Data;
                mt88param = "0100,0080";
            }
            else if (cmdtext == _CommandExpression_ReadIPPort) {
                mt88cmd = EnumMT88Command.Read_EEP_Data;
                mt88param = "0087,0079";
            }
            else if (cmdtext == _CommandExpression_ReadAPN) {
                mt88cmd = EnumMT88Command.Read_EEP_Data;
                mt88param = "0000,0080";
            }
            else if (cmdtext == _SettingTool_ReadAllParams) {
                mt88cmd = EnumMT88Command.SetRead_EEP_Ext;
                var e01all = getReadSMSTrackingStr()
								+ getReadGPRSTrackingStr()
								+ getReadGPRSTracking1Str()
								+ getReadMainStr()
								+ getReadEventHeaderStr()
								+ getReadSMSAuthStr()
								+ getReadPhotoAuthStr()
								+ getReadGeoFenceStr();
                mt88param = "01" + e01all;
            }
            else if (cmdtext == _CommandExpression_EngineCheck) {
                mt88cmd = EnumMT88Command.Set_Engine_Check;
                mt88param = cmbparams1.getValue();
                cmd = EnumGPRSCommand.CheckEngineFirst;
                param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_3DWakeUpSet) {
                mt88cmd = EnumMT88Command.Set3D_Shake_Wake_Up;
                mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_CancelOTA) {
                mt88smscmd = mt88cmd = EnumMT88Command.OTA_CANCEL;
            }
            else if (cmdtext == _CommandExpression_FuelAlarmSettings) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_WanDi_Fuel;
                mt88smsparam = mt88param = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_SetFuelDown) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_Fuel_Down;
                mt88smsparam = mt88param = txtparams1.getValue() + "," + txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_UserDefinedCommand) {
                mt88smscmd = mt88cmd = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_AsyncExtendSensor) {
                mt88smscmd = mt88cmd = EnumMT88Command.Get_Ext_Sensor_Info;
            }
            /*********************越南定制项目***************/
            else if (cmdtext == _CommandExpression_PulseCalibration) {
                mt88smscmd = mt88cmd = EnumMT88Command.EXT_Cancel_PulseCalibratio;
                mt88smsparam = mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_InformationCharacter) {
                mt88smscmd = mt88cmd = EnumMT88Command.EXT_InformationCharacter;
                mt88smsparam = mt88param = cmbparams1.getValue() + "," + txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_SetPrintPeriod) {
                //                var s = Ext.getCmp('datetime_gb_start_date').getEl().dom.value +
                //                             ' ' + Ext.getCmp('datetime_gb_start_time').getEl().dom.value;
                //                var startDateTime = new Date(Date.parse(s.replace(/-/g, "/"))).format("yyMMddhhmmss");
                //                
                //                s = Ext.getCmp('datetime_gb_end_date').getEl().dom.value +
                //                             ' ' + Ext.getCmp('datetime_gb_end_time').getEl().dom.value;
                //                var endDateTime = new Date(Date.parse(s.replace(/-/g, "/"))).format("yyMMddhhmmss");
                //                
                //                mt88smscmd = mt88cmd = EnumMT88Command.EXT_SetPrintPeriod;
                //                mt88smsparam = mt88param = startDateTime + "," + endDateTime;
                mt88smscmd = mt88cmd = EnumMT88Command.EXT_SetPrintPeriod;
                mt88smsparam = mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_CheckIgnition) {
                mt88smscmd = mt88cmd = EnumMT88Command.Check_ignition_onoff;
                mt88smsparam = mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_GPRSIntervalWhenIgnitionOff) {
                mt88smscmd = mt88cmd = EnumMT88Command.Track_on_interval_when_ignition_off;
                mt88smsparam = mt88param = txtparams1.getValue() + ",0"; //+ txtparams2.getValue();
            }
            else if (cmdtext == _CommandExpression_SetFuelAlarm) {
                mt88smscmd = mt88cmd = EnumMT88Command.Set_Fuel_Alarm;
                mt88smsparam = mt88param = txtparams1.getValue();
            }
            else if (cmdtext == _CommandExpression_RFIDOut1) {
                mt88smscmd = mt88cmd = EnumMT88Command.RFID_Control_Out1;
                mt88smsparam = mt88param = cmbparams1.getValue();
            }
            else if (cmdtext == 'Test') {
                mt88cmd = 'ABC';
                mt88param = '';
            }
            else if (cmdtext == _CommandExpression_LED) {
                //********************************LED******************************************/
                var cmdledtext = cmdledcommand.getRawValue();
                mt88cmd = EnumMT88Command.EXT_LED_Command;
                if (cmdledtext == _CommandExpression_LED_AddAdvertisement) {
                }
                else if (cmdledtext == _CommandExpression_LED_DelAdvertisement) {
                }
                else if (cmdledtext == _CommandExpression_LED_DelAllAdvertisement) {
                    mt88param = getLEDFullHexString(EnumLEDCommand.DelAllAdv, "");
                }
                else if (cmdledtext == _CommandExpression_LED_GetAdvertisementCount) {
                    mt88param = getLEDFullHexString(EnumLEDCommand.GetAdvCount, "");
                }
                else if (cmdledtext == _CommandExpression_LED_GetAdvertisement) {
                    mt88param = getLEDFullHexString(EnumLEDCommand.GetOneAdv, UInt8ToByteString(txtparams1.getValue()));
                }
                else if (cmdledtext == _CommandExpression_LED_SendMessage) {
                    var bodyhex = UInt8ToByteString(cmbparams1.getValue()) + UInt8ToByteString(cmbparams2.getValue());
                    var t = Ext.getCmp('sendmessagedate').getEl().dom.value;
                    var tmp = t.split(':');
                    var tseconds = parseInt(tmp[0]) * 3600 + parseInt(tmp[1]) * 60;
                    bodyhex += UInt32ToDWORDStringNoComm(tseconds);
                    bodyhex += UInt16ToWORDStringNoComm(txtparams1.getValue());
                    bodyhex += UInt8ToByteString(txtparams2.getValue());
                    bodyhex += UInt8ToByteString(cmbparams3.getValue()) + UInt8ToByteString(cmbparams4.getValue()) +
                    UInt8ToByteString(cmbparams5.getValue()) + UInt8ToByteString(cmbparams6.getValue()) + UInt8ToByteString(txtparams3.getValue()) + UInt8ToByteString(txtparams4.getValue());
                    bodyhex += UInt8ToByteString(Math.floor(Math.random() * 0xFF));
                    //var txthex = encodeGBKNoComm(ToDBC(txtparams5.getValue()));
                    txthex = encodeGBKNoComm(txtparams5.getValue());
                    mt88param = getLEDFullHexString(EnumLEDCommand.SendImmeMsg, bodyhex + txthex);
                }
                else if (cmdledtext == _CommandExpression_LED_BreakMessage) {
                    mt88param = getLEDFullHexString(EnumLEDCommand.StopImmeMsg, "");
                }
                else if (cmdledtext == _CommandExpression_LED_SetAlarm) {
                    var bodyhex = UInt8ToByteString(cmbparams1.getValue());
                    var txthex = padRight(encodeGBKNoComm(txtparams2.getValue()), '20', 32);
                    mt88param = getLEDFullHexString(EnumLEDCommand.SetAlarmMsg, bodyhex + txthex);
                }
                else if (cmdledtext == _CommandExpression_LED_ShowAlarm) {
                    mt88param = getLEDFullHexString(EnumLEDCommand.ShowAlarmMsg, UInt16ToWORDStringNoComm(txtparams1.getValue()));
                }
                else if (cmdledtext == _CommandExpression_LED_HideAlarm) {
                    mt88param = getLEDFullHexString(EnumLEDCommand.HideAlarmMsg, "");
                }
                else if (cmdledtext == _CommandExpression_LED_SetDefaultMessage) {
                    var bodyhex = UInt8ToByteString(cmbparams6.getValue()) +
                        UInt8ToByteString(cmbparams1.getValue()) +
                        UInt8ToByteString(cmbparams2.getValue()) +
                        UInt8ToByteString(cmbparams3.getValue()) +
                        UInt8ToByteString(cmbparams4.getValue()) +
                        UInt8ToByteString(txtparams4.getValue()) +
                        UInt8ToByteString(cmbparams5.getValue());
                    //var txthex = encodeGBKNoComm(ToDBC(txtparams5.getValue()));
                    var txthex = encodeGBKNoComm(txtparams5.getValue());
                    mt88param = getLEDFullHexString(EnumLEDCommand.SetDefaultMsg, bodyhex + txthex);
                }
                else if (cmdledtext == _CommandExpression_LED_SetTime) {
                    var s = Ext.getCmp('correctdate').getEl().dom.value +
                         ' ' + Ext.getCmp('correcttime').getEl().dom.value;
                    var dtime = new Date(Date.parse(s.replace(/-/g, "/")));
                    var bodyhex = UInt8ToByteString(dtime.getFullYear() - 2000) + UInt8ToByteString(dtime.getMonth() + 1) + UInt8ToByteString(dtime.getDate()) + UInt8ToByteString(dtime.getDay())
                        + UInt8ToByteString(dtime.getHours()) + UInt8ToByteString(dtime.getMinutes()) + UInt8ToByteString(dtime.getSeconds());
                    mt88param = getLEDFullHexString(EnumLEDCommand.SetTime, bodyhex);

                }
                else if (cmdledtext == _CommandExpression_LED_GetTime) {
                    mt88param = getLEDFullHexString(EnumLEDCommand.GetTime, "");
                }
                else if (cmdledtext == _CommandExpression_LED_SetBrightness) {
                    var bodyhex = UInt8ToByteString(cmbparams1.getValue()) + UInt8ToByteString(cmbparams2.getValue());
                    var time1 = UInt16ToWORDStringNoComm(timerToSeconds(Ext.getCmp('btime1').getValue()));
                    var time2 = UInt16ToWORDStringNoComm(timerToSeconds(Ext.getCmp('btime2').getValue()));
                    var time3 = UInt16ToWORDStringNoComm(timerToSeconds(Ext.getCmp('btime3').getValue()));
                    var time4 = UInt16ToWORDStringNoComm(timerToSeconds(Ext.getCmp('btime4').getValue()));
                    var v1 = UInt8ToByteString(cmbparams3.getValue());
                    var v2 = UInt8ToByteString(cmbparams4.getValue());
                    var v3 = UInt8ToByteString(cmbparams5.getValue());
                    var v4 = UInt8ToByteString(cmbparams6.getValue());
                    mt88param = getLEDFullHexString(EnumLEDCommand.SetLightLevel, bodyhex + time1 + time2 + time3 + time4 + v1 + v2 + v3 + v4);
                }
                else if (cmdledtext == _CommandExpression_LED_GetBrightness) {
                    mt88param = getLEDFullHexString(EnumLEDCommand.GetLightLevel, "");
                }
                else if (cmdledtext == _CommandExpression_LED_SetPowerOnWaitingTime) {
                    var bodyhex = padLeft(txtparams1.getValue().toString(16), '0', 2);
                    mt88param = getLEDFullHexString(EnumLEDCommand.SetPowerOnWaitTime, bodyhex);
                }
                else if (cmdledtext == _CommandExpression_LED_SearchWorkingStatus) {
                    mt88param = getLEDFullHexString(EnumLEDCommand.GetWorkState, "");
                }
                else if (cmdledtext == _CommandExpression_LED_TimerSwitch) {
                    var bodyhex = UInt8ToByteString(cmbparams1.getValue());
                    var timebegin = Ext.getCmp('workbegintime').getValue();
                    var timeend = Ext.getCmp('workendtime').getValue();
                    var tbegin = timerToSeconds(timebegin);
                    var tend = timerToSeconds(timeend);
                    mt88param = getLEDFullHexString(EnumLEDCommand.SetAutoPowerOnOffTime, bodyhex + UInt16ToWORDStringNoComm(tbegin) + UInt16ToWORDStringNoComm(tend));
                }
                else if (cmdledtext == _CommandExpression_LED_LEDSwitch) {
                    var bodyhex = UInt8ToByteString(cmbparams1.getValue());
                    mt88param = getLEDFullHexString(EnumLEDCommand.SetLED, bodyhex);
                }
                else if (cmdledtext == _CommandExpression_LED_LightTest) {
                    var bodyhex = UInt8ToByteString(txtparams1.getValue());
                    mt88param = getLEDFullHexString(EnumLEDCommand.TestLEDLight, bodyhex);
                }
                else if (cmdledtext == _CommandExpression_LED_SetBaudrate) {
                    var bodyhex = UInt8ToByteString(cmbparams1.getValue());
                    mt88param = getLEDFullHexString(EnumLEDCommand.SetBaudrate, bodyhex);

                }
                
            }
            ///************************GB tracker********************************************/ 
            else if (cmdtext == _CommandExpression_GBControlTracker) {
                gbcommand = "8105";
                var ccc = parseInt(cmbparams1.getValue());
                if (ccc == 1 || ccc == 2) {
                    gbparamdata = ccc.toString(16) + "," + encodeGBK(txtparams2.getValue());
                } else
                    gbparamdata = ccc.toString(16);
            }
            else if (cmdtext == _CommandExpression_GBCheckParams) {
                gbcommand = "8104";
            }
            else if (cmdtext == _CommandExpression_GBSendText) {
                gbcommand = "8300";
                var ary = cmbparams1.getValue().split(",");
                var binData = "00000000";
                var i;
                for (i = 0; i < ary.length; i++) {
                    binData = bitSet(binData, parseInt(ary[i]), 1);
                }
                var gbkString = encodeGBK(txtparams2.getValue());
                gbparamdata = binStringToHexString(binData) + "," + gbkString;
                //intStringToHexString(gbkString.split(',').length) + "," 
            }

            else if (cmdtext == _CommandExpression_GBCheckLocation) {
                gbcommand = "8201";
            }

            else if (cmdtext == _CommandExpression_GBTempLocationTrack) {
                gbcommand = "8202";
                gbparamdata = UInt16ToWORDString(txtparams1.getValue()) + "," + UInt32ToDWORDString(txtparams2.getValue());

            }
            else if (cmdtext == _CommandExpression_GBManulaParams) {
                gbcommand = txtparams1.getValue();
                gbparamdata = txtparams2.getValue();
            }

            else if (cmdtext == _CommandExpression_GBSetGeoFence) {
                var areaType = panelgbareadefaultparams.items.items[0].getValue();
                var areaControl = panelgbareadefaultparams.items.items[1].getValue();

                var gbParamsArray = new Array();

                if (areaControl != 3) {
                    if (!checkGBValid()) return;
                    var areaCount = panelgbareadefaultparams.items.items[2].getValue();
                    var areaId = panelgbareadefaultparams.items.items[3].getValue();
                    var areaPropertyArray = panelgbareadefaultparams.items.items[4].getValue().split(',');
                    var areapropertyBit = padLeft('', '0', 16);
                    if (panelgbareadefaultparams.items.items[5].getValue() == 1) {
                        if (areaType != 3) {
                            areaPropertyArray.push(6);
                        }
                    }
                    if (panelgbareadefaultparams.items.items[6].getValue() == 1) {
                        if (areaType != 3) {
                            areaPropertyArray.push(7);
                        }
                    }
                    for (var i = 0; i < areaPropertyArray.length; i++) {
                        if (areaPropertyArray[i] != "") {
                            areapropertyBit = bitSet(areapropertyBit, parseInt(areaPropertyArray[i]), 1);
                        }
                    }
                    if (areaType == 0 || areaType == 1) {
                        gbParamsArray.push(areaControl);
                        gbParamsArray.push(areaCount);
                    }
                    gbParamsArray.push(UInt32ToDWORDString(areaId));
                    gbParamsArray.push(binStringToWORDString(areapropertyBit));
                    if (areaType == "" || areaType == undefined || areaType == null ||
                areaControl == "" || areaControl == undefined || areaControl == null) return;
                    if (areaType == 0) {
                        gbcommand = "8600";
                        var centerLatitude = Ext.getCmp('txt_circle_latitude').getValue().toFixed(6);
                        var centerLongitude = Ext.getCmp('txt_circle_longitude').getValue().toFixed(6);
                        var radius = Ext.getCmp('txt_circle_radius').getValue();
                        gbParamsArray.push(UInt32ToDWORDString(centerLatitude * 1000000));
                        gbParamsArray.push(UInt32ToDWORDString(centerLongitude * 1000000));
                        gbParamsArray.push(UInt32ToDWORDString(radius));
                        pushStartEndDateTimeAndSpeedParams(gbParamsArray);

                    }
                    else if (areaType == 1) {
                        gbcommand = "8602";
                        var upperLeftLatitude = Ext.getCmp('txt_upper_left_latitude').getValue().toFixed(6);
                        var upperLeftLongitude = Ext.getCmp('txt_upper_left_longitude').getValue().toFixed(6);
                        var lowerRightLatitude = Ext.getCmp('txt_lower_right_latitude').getValue().toFixed(6);
                        var lowerRightLongitude = Ext.getCmp('txt_lower_right_longitude').getValue().toFixed(6);
                        gbParamsArray.push(UInt32ToDWORDString(upperLeftLatitude * 1000000));
                        gbParamsArray.push(UInt32ToDWORDString(upperLeftLongitude * 1000000));
                        gbParamsArray.push(UInt32ToDWORDString(lowerRightLatitude * 1000000));
                        gbParamsArray.push(UInt32ToDWORDString(lowerRightLongitude * 1000000));
                        pushStartEndDateTimeAndSpeedParams(gbParamsArray);
                    }
                    else if (areaType == 2) {
                        gbcommand = "8604";
                        pushStartEndDateTimeAndSpeedParams(gbParamsArray);
                        Ext.each(paramsArray, function(item, index) {
                            gbParamsArray.push(item);
                        });

                    }
                    else if (areaType == 3) {
                        gbcommand = "8606";
                        pushStartEndDateTimeAndSpeedParams(gbParamsArray);
                        Ext.each(paramsArray, function(item, index) {
                            gbParamsArray.push(item);
                        });
                    }
                    gbparamdata = changeArrayToString(gbParamsArray);
                }
                else {
                    var tmp = Ext.getCmp('t_delid').getValue();
                    if (tmp.length > 0) {
                        var gids = tmp.split(',');
                        gbparamdata = gids.length.toString(16);
                        var i;
                        for (i = 0; i < gids.length; i++) {
                            gbparamdata += "," + UInt32ToDWORDString(parseInt(gids[i]));
                        }
                        if (areaType == 0) {
                            gbcommand = "8601";
                        }
                        else if (areaType == 1) {
                            gbcommand = "8603";
                        }
                        else if (areaType == 2) {
                            gbcommand = "8605";
                        }
                        else if (areaType == 3) {
                            gbcommand = "8607";
                        }
                    }
                }
            }
            else if (cmdtext == _CommandExpression_GBSetEvent) {
                gbcommand = "8301";
                if (cmbparams1.getValue() == "0") {
                    gbparamdata = "00";
                }
                else {
                    var eventContent = encodeGBK(txtparams3.getValue());
                    gbparamdata = cmbparams1.getValue() + "," +
                    intStringToHexString(txtparams1.getValue()) + "," +
                    intStringToHexString(txtparams2.getValue()) + "," +
                   intStringToHexString(eventContent.split(',').length) + "," + eventContent;
                }
            }
            else if (cmdtext == _CommandExpression_GBQuestion) {
                gbcommand = "8302";
                var quertionSign = padLeft('', '0', 8);
                var signIndex = cmbparams1.getValue();
                Ext.each(signIndex.split(','), function(item, index) {
                    if (!Ext.isEmpty(item)) {
                        quertionSign = bitSet(quertionSign, parseInt(item), 1);
                    }
                });
                var myQuestion = encodeGBK(txtparams1.getValue());
                var questionLength = myQuestion.split(',').length;
                gbparamdata = binStringToHexString(quertionSign) + "," +
                intStringToHexString(questionLength) + "," + myQuestion;
                var answers = panelparamscolumn1.find('name', "txt_question_for_answer");
                Ext.each(answers, function(item, index) {
                    var answersContent = encodeGBK(item.getValue());
                    gbparamdata += "," + index + "," + UInt16ToWORDString(answersContent.split(',').length) + "," + answersContent
                });

            }
            else if (cmdtext == _CommandExpression_GBSetMenu) {
                gbcommand = "8303";
                if (cmbparams1.getValue() == "0") {
                    gbparamdata = "00";
                }
                else {
                    var messageName = encodeGBK(txtparams2.getValue());
                    gbparamdata = cmbparams1.getValue() + "," + intStringToHexString(txtparams1.getValue()) + ","
                    + cmbparams2.getValue() + "," + UInt16ToWORDString(messageName.split(',').length) + "," + messageName;
                }
            }
            else if (cmdtext == _CommandExpression_GBInfoService) {
                gbcommand = "8304";
                var messageContent = encodeGBK(txtparams1.getValue());
                gbparamdata = cmbparams1.getValue() + "," + UInt16ToWORDString(messageContent.split(',').length) + "," + messageContent;
            }
            else if (cmdtext == _CommandExpression_GBPhoneTo) {
                gbcommand = "8400";
                gbparamdata = cmbparams1.getValue() + ',' + encodeGBK(txtparams1.getValue());
            }
            else if (cmdtext == _CommandExpression_GBSetPhoneBook) {
                gbcommand = "8401";
                if (cmbparams1.getValue() == "0") {
                    gbparamdata = "00";
                }
                else {
                    var myflags = panelparamscolumn1.find('name', "cmb_contact_flag");
                    var mynumbers = panelparamscolumn1.find('name', "txt_contact_phonenumber");
                    var mynames = panelparamscolumn1.find('name', "txt_contact_username");

                    var mm;
                    gbparamdata = cmbparams1.getValue() + "," + intStringToHexString(myflags.length);
                    for (mm = 0; mm < myflags.length; mm++) {
                        var flag = myflags[mm].getValue();
                        var phoneNo = encodeGBK(mynumbers[mm].getValue());
                        var contact = encodeGBK(mynames[mm].getValue());
                        gbparamdata += "," + flag + "," + intStringToHexString(phoneNo.split(',').length) + "," + phoneNo + ',' + intStringToHexString(contact.split(',').length) + "," + contact;
                    }
                    alert(gbparamdata);
                }
            }
            else if (cmdtext == _CommandExpression_GBControlVehicle) {
                gbcommand = "8500";
                var controlSign = padLeft('', '0', 8);
                controlSign = bitSet(controlSign, 0, radiogroupparam1.getValue().inputValue);
                gbparamdata = binStringToHexString(controlSign);
            }

            else if (cmdtext == _CommandExpression_GBSetLog) {
                gbcommand = "8700";
                gbparamdata = cmbparams1.getValue();
            }

            else if (cmdtext == _CommandExpression_GBLogParamSet) {
                gbcommand = "8701";
                var dataAreas = panelparamscolumn1.find("name", "txt_data_area");
                var dataAreaString = "";
                Ext.each(dataAreas, function(item, index) {
                    dataAreaString += item.getValue();
                });
                gbparamdata = cmbparams1.getValue().toString(16) + "," + encodeGBK(dataAreaString);
                var dataHex = panelparamscolumn1.find("name", "txt_hex_data");
                var strHex = "";
                Ext.each(dataHex, function(item, index) {
                    strHex += item.getValue();
                });
                gbparamdata += strHex;
            }
            else if (cmdtext == _CommandExpression_GBTakePhoto) {
                gbcommand = "8801";
                Ext.each(panelparamscolumn1.find('name', 'param_gb_shoot'), function(item, index) {
                    var data = item.getValue();
                    if (index == 0) {
                        gbparamdata = intStringToHexString(data);
                    }
                    else {

                        if (index == 1) {
                            var tmp = parseInt(item.getValue());
                            data = UInt16ToWORDString(tmp);
                            gbparamdata += "," + data;
                        }
                        else if (index == 2) {
                            data = UInt16ToWORDString(item.getValue());
                            gbparamdata += "," + data;
                        }
                        else
                            gbparamdata += "," + intStringToHexString(data);
                    }
                });
            }
            else if (cmdtext == _CommandExpression_GBMultimediaSearch) {
                gbcommand = "8802";
                Ext.each(panelparamscolumn1.find('name', 'param_gb_media_search'), function(item, index) {
                    var data = intStringToHexString(item.getValue());
                    if (index == 0) {
                        gbparamdata = data;
                    }
                    else {
                        gbparamdata += "," + data;
                    }
                });
                var s = Ext.getCmp('datetime_gb_start_date').getEl().dom.value +
                         ' ' + Ext.getCmp('datetime_gb_start_time').getEl().dom.value;
                var startDateTime = new Date(Date.parse(s.replace(/-/g, "/")));

                s = Ext.getCmp('datetime_gb_end_date').getEl().dom.value +
                         ' ' + Ext.getCmp('datetime_gb_end_time').getEl().dom.value;
                var endDateTime = new Date(Date.parse(s.replace(/-/g, "/")));

                gbparamdata += "," + DateToBCDString(startDateTime);
                gbparamdata += "," + DateToBCDString(endDateTime);
            }
            else if (cmdtext == _CommandExpression_GBMultimediaUpload) {
                gbcommand = "8803";
                var items = panelparamscolumn1.find('name', 'param_gb_media_upload');
                var deleteSign = "0";
                Ext.each(items, function(item, index) {
                    var data = intStringToHexString(item.getValue());
                    if (index == 0) {
                        gbparamdata = data;
                    }
                    else {
                        if (index == items.length) {
                            deleteSign = data;
                        }
                        else {
                            gbparamdata += "," + data;
                        }
                    }
                });

                var s = Ext.getCmp('datetime_gb_start_date').getEl().dom.value +
                         ' ' + Ext.getCmp('datetime_gb_start_time').getEl().dom.value;
                var startDateTime = new Date(Date.parse(s.replace(/-/g, "/")));

                s = Ext.getCmp('datetime_gb_end_date').getEl().dom.value +
                         ' ' + Ext.getCmp('datetime_gb_end_time').getEl().dom.value;
                var endDateTime = new Date(Date.parse(s.replace(/-/g, "/")));

                gbparamdata += "," + DateToBCDString(startDateTime);
                gbparamdata += "," + DateToBCDString(endDateTime);

                gbparamdata += "," + deleteSign;
            }
            else if (cmdtext == _CommandExpression_GBBeginRecordVoice) {
                gbcommand = "8804";
                var items = panelparamscolumn1.find('name', 'param_gb_voice_record');
                Ext.each(items, function(item, index) {
                    var value = item.getValue();
                    if (index == 0) {
                        gbparamdata = intStringToHexString(value);
                    }
                    else {

                        if (index == 1) {
                            value = UInt16ToWORDString(value);
                            gbparamdata += "," + value;
                        }
                        else
                            gbparamdata += "," + intStringToHexString(value);
                    }
                });
            }
            else if (cmdtext == _CommandExpression_GBTransData) {
                gbcommand = "8900";
                gbparamdata = txtparams1.getValue();
            }
           
            if (checkValid()) {
                if (showSMS) {
                    if (gprsorsmsgroup.getValue().inputValue == 0)
                        addTCPOrSMSCommand('HandlerSendCommand', cmd, param, mt88cmd, mt88param, gbcommand, gbparamdata);
                    else {
                        addTCPOrSMSCommand('HandlerSendSMSCommand', smscmd, smsparam, mt88smscmd, mt88smsparam);
                    }
                }
                else
                    addTCPOrSMSCommand('HandlerSendCommand', cmd, param, mt88cmd, mt88param, gbcommand, gbparamdata);
            }
        }
    }
}



function checkValid() {
    var r = true;
    if (txtparams1 != null)
        r = r & txtparams1.isValid();
    if (txtparams2 != null)
        r = r & txtparams2.isValid();
    if (txtparams3 != null)
        r = r & txtparams3.isValid();
    if (txtparams4 != null)
        r = r & txtparams4.isValid();
    Ext.each(panelparamscolumn1.items.items, function(item, index) {
        r = r & item.isValid();
    });
    
    return r;
}

function checkGBValid() {
    var r = true;
    var defaultItems = panelgbareadefaultparams.items.items;
    var otherItems = panelgbareaotherparams.items.items;

    Ext.each(defaultItems, function(item, index) {
        if (Ext.isFunction(item.isValid))
            r = r & item.isValid();
    }, this);
    Ext.each(otherItems, function(item, index) {
        if (Ext.isFunction(item.isValid))
            r = r & item.isValid();
    }, this);
    return r;
}


function getGPRSMessageLevelString(level) {
    var s = "";
    if (level == "1") {
        s = _TrackerMain_GPRSMessageServerRequest;
    }
    else if (level == "2") {
        s = _TrackerMain_GPRSMessageTerminalAsk;
    }
    else if (level == "3") {
        s = _TrackerMain_GPRSMessageServerMessage;
    }
    else if (level == "4") {
        s = _TrackerMain_GPRSMessageTerminalResponse;
    }
    else if (level == "5") {
        s = _TrackerMain_GPRSMessageTerminalSendData;
    }
    else if (level == "6") {
        s = _TrackerMain_GPRSMessageServerResponse;
    }
    else if (level == "A1") {
        s = _TrackerMain_GPRSMessageTerminalForResponse;
    }
    else if (level == "ALARM") {
        s = _TrackerMain_GPRSMessageAlarmMessage;
    }
    return s;
}

/************************Search Alarm Message Part*********************/

var gprsAlarmMessageFields = ["sn_imei_id", "message_r_datetime", "message_level", "message_body", "send_or_received", { name: "completed", type: 'boolean'}];
var gprsAlarmMessageStore = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        url: "HandlerSearchGprsMessage",
        method: "GET"
    }),
    reader: new Ext.data.JsonReader({
        fields: gprsAlarmMessageFields,
        root: "data",
        totalProperty: "totalCount"
    })
});



gprsAlarmMessageStore.addListener('load', function(str, records) {
    var i;
    for (i = 0; i < records.length; i++) {
        var record = records[i];
        var level = "ALARM";
        var time = record.get('message_r_datetime');
        var sssid = record.get('sn_imei_id');
        var index = devicestore.find('sssid', sssid);
        var txt = record.get('message_body');
        var trackername = "";
        if (index != -1) {
            trackername = devicestore.getAt(index).get('trackername');
        }

        // time = time.substr(0, 2) + "-" + time.substr(2, 2) + "-" + time.substr(4, 2) + " " + time.substr(6, 2) + ":" + time.substr(8, 2) + ":" + time.substr(10, 2);

        if (g_GPRSAlarmWindowDictinary.ContainsKey(sssid)) {
            var mwinclass = g_GPRSAlarmWindowDictinary.Item(sssid);
            mwinclass.setNewText(trackername + " " + time, level, txt);

        }
        else {
            var mwinclass = new GPRSMessageReceivedWin(trackername + " " + time, "", level, txt, sssid);
            mwinclass.messagewin.show();
            g_GPRSAlarmWindowDictinary.Add(sssid, mwinclass);
        }

    }
});
function searchGPRSAlarmMessageInfo() {
    var sssids = "";
    var hasMVT600orT1 = false;
    devicestore.each(function(record) {
        var dtype = record.get('devicetype');
        if (dtype == '8' || dtype == '13' || dtype =='15') {
            if (sssids.length == 0) {
                sssids += record.get("sssid");
            } else {
                sssids += "," + record.get("sssid");
            }
            hasMVT600orT1 = true;
        }
    });
    gprsAlarmMessageStore.baseParams = { snids: sssids,
        fromtime: '2000-1-1 00:00:00',
        totime: '2099-1-1 00:00:00',
        start: 0,
        limit: 65535,
        method: '1',
        level: '1',
        onlyNoCompleted: 1
    };
    if (hasMVT600orT1)
        gprsAlarmMessageStore.reload();
     
}
var g_GPRSAlarmWindowDictinary;
if (showAlarmWindow) {
    setInterval('searchGPRSAlarmMessageInfo()', 35000);
    g_GPRSAlarmWindowDictinary = new Dictionary();
}

/************************Search Alarm Message Part*********************/

function GPRSMessageReceivedWin(trackername, flag, level, txt, sssid) {
    this.messagewin;
    this.txttype = new Ext.form.TextField({
        style: 'padding-top:10px',
        labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
        fieldLabel: _TrackerMain_GPRSMessageType,
        value: getGPRSMessageLevelString(level),
        readOnly: true
    });
    this.txtbody = new Ext.form.TextArea({
        style: 'padding-top:10px',
        labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
        fieldLabel: _TrackerMain_Text,
        value: txt,
        width: 250,
        readOnly: true
    });
    this.btnCompletedGPRSAlarm = new Ext.Button({
        text: _TrackerMain_CompleteAlarm,
        handler: function() {
            Ext.Ajax.request({
                url: 'HandlerCompleteGPRSAlarm',
                method: 'post',
                params: {
                    sssid: sssid
                },
                success: function(back) {
                    var val = back.responseText;
                    if (val == 1) {
                        if (g_GPRSAlarmWindowDictinary.ContainsKey(sssid)) {
                            var winclass = g_GPRSAlarmWindowDictinary.Item(sssid);
                            winclass.messagewin.close();
                        }
                    }
                }
            });

        }
    });
    this.setNewText = function(newtitle, newtype, newbody) {
        this.messagewin.setTitle(_TrackerMain_MessageReceived + "(" + newtitle + ")");
        this.txttype.setValue(getGPRSMessageLevelString(newtype));
        this.txtbody.setValue(newbody);
    };
    if (level != "2") {
        this.messagewin = new Ext.Window({
            title: _TrackerMain_MessageReceived + "(" + trackername + ")",
            layout: 'form',
            height: 180,
            width: 400,
            x: nextwindowx,
            y: nextwindowy,
            constrain:true,
            //iconCls: 'report-alarm',
            items: [this.txttype, this.txtbody],
            minimizable: true,
            listeners: {
                'minimize': function() {
                    addTaskButtonForWindow(messagewin);
                }
            }
        });
        if (level == "ALARM")
            this.messagewin.addButton(this.btnCompletedGPRSAlarm);
    }
    else {
        //终端抢答
        this.txtControlMessage = new Ext.form.TextArea({
            //style: 'padding-top:10px',
            labelStyle: 'padding-top:6px;padding-left:10px;text-align: left',
            fieldLabel: _TrackerMain_GPRSControlMessage,
            value: '',
            width: 250,
            readOnly: false
        });
        this.btnSendControlMessage = new Ext.Button({
            text: _TrackerMain_SendControlMessage,
            style: 'padding-left:16px',
            width: 80,
            handler: function() {
                var mt88cmd = EnumMT88Command.GRPS_Recieved_Message;
                var body = txtControlMessage.getValue();
                var codetype = "E";
                if (isUnicode(body)) {
                    codetype = "U";
                    body = toUnicode(body);
                }
                var mt88param = "3," + flag + "," + codetype + "," + body;
                addOneTCPCommand(sssid, 0, 0, mt88cmd, mt88param);
            }
        });

        this.messagewin = new Ext.Window({
            title: _TrackerMain_MessageReceived + "(" + trackername + ")",
            layout: 'form',
            height: 280,
            width: 400,
        
            x: nextwindowx,
            y: nextwindowy,
            //iconCls: 'report-alarm',
            items: [this.txttype, this.txtbody, this.txtControlMessage, this.btnSendControlMessage],
            constrain:true,    
            minimizable: true,
            listeners: {
                'minimize': function() {
                    addTaskButtonForWindow(messagewin);
                }
            }
        });

    }
    this.messagewin.addListener('close', function() {
        if (g_GPRSAlarmWindowDictinary.ContainsKey(sssid)) {
            g_GPRSAlarmWindowDictinary.Remove(sssid);
        }
    });
    nextwindowx += 20;
    nextwindowy += 10;
    return this;
}